7
7
WEBPACK_DEV_SERVER_VERSION ,
8
8
} from './sandbox/WebpackDevServerDriver' ;
9
9
import { FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION } from './sandbox/Plugin' ;
10
- import semver from 'semver/preload' ;
11
10
12
11
describe ( 'TypeScript Vue Extension' , ( ) => {
13
12
let sandbox : Sandbox ;
@@ -30,23 +29,21 @@ describe('TypeScript Vue Extension', () => {
30
29
typescript : '^3.8.0' ,
31
30
tsloader : '^7.0.0' ,
32
31
vueloader : '^15.8.3' ,
33
- vue : '^2.0.0 ' ,
32
+ vue : '^2.6.11 ' ,
34
33
compiler : 'vue-template-compiler' ,
35
- qrcodevue : '^1.7.0' ,
36
34
} ,
37
35
{
38
36
async : true ,
39
37
typescript : '^3.8.0' ,
40
38
tsloader : '^7.0.0' ,
41
- vueloader : 'v16.8 .3' ,
42
- vue : '^3.0.0' ,
39
+ vueloader : 'v16.0.0-beta .3' ,
40
+ vue : '^3.0.0-beta.14 ' ,
43
41
compiler : '@vue/compiler-sfc' ,
44
- qrcodevue : '^3.0.0' ,
45
42
} ,
46
43
] ) (
47
44
'reports semantic error for %p' ,
48
- async ( { async, typescript, tsloader, vueloader, vue, compiler, qrcodevue } ) => {
49
- const fixtures = [
45
+ async ( { async, typescript, tsloader, vueloader, vue, compiler } ) => {
46
+ await sandbox . load ( [
50
47
await readFixture ( join ( __dirname , 'fixtures/environment/typescript-vue.fixture' ) , {
51
48
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION : JSON . stringify (
52
49
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION
@@ -59,23 +56,12 @@ describe('TypeScript Vue Extension', () => {
59
56
VUE_LOADER_VERSION : JSON . stringify ( vueloader ) ,
60
57
VUE_VERSION : JSON . stringify ( vue ) ,
61
58
VUE_COMPILER : JSON . stringify ( compiler ) ,
62
- QRCODE_VUE_VERSION : JSON . stringify ( qrcodevue ) ,
63
59
ASYNC : JSON . stringify ( async ) ,
64
60
} ) ,
65
- await readFixture ( join ( __dirname , 'fixtures/implementation/typescript-vue-shared.fixture' ) ) ,
66
- ] ;
67
- if ( semver . satisfies ( '2.0.0' , vue ) ) {
68
- fixtures . push (
69
- await readFixture ( join ( __dirname , 'fixtures/implementation/typescript-vue2.fixture' ) )
70
- ) ;
71
- } else if ( semver . satisfies ( '3.0.0' , vue ) ) {
72
- fixtures . push (
73
- await readFixture ( join ( __dirname , 'fixtures/implementation/typescript-vue3.fixture' ) )
74
- ) ;
75
- }
76
- await sandbox . load ( fixtures ) ;
61
+ await readFixture ( join ( __dirname , 'fixtures/implementation/typescript-vue.fixture' ) ) ,
62
+ ] ) ;
77
63
78
- if ( semver . satisfies ( '2.0.0' , vue ) ) {
64
+ if ( vue === '^2.6.11' ) {
79
65
await sandbox . write (
80
66
'src/vue-shim.d.ts' ,
81
67
[
@@ -85,7 +71,7 @@ describe('TypeScript Vue Extension', () => {
85
71
'}' ,
86
72
] . join ( '\n' )
87
73
) ;
88
- } else if ( semver . satisfies ( '3.0.0' , vue ) ) {
74
+ } else {
89
75
await sandbox . write ( 'src/vue-shim.d.ts' , 'declare module "*.vue";' ) ;
90
76
}
91
77
@@ -112,7 +98,7 @@ describe('TypeScript Vue Extension', () => {
112
98
'ERROR in src/component/LoggedIn.vue:27:21' ,
113
99
"TS2304: Cannot find name 'getUserName'." ,
114
100
' 25 | const user: User = this.user;' ,
115
- ' 26 |' ,
101
+ ' 26 | ' ,
116
102
" > 27 | return user ? getUserName(user) : '';" ,
117
103
' | ^^^^^^^^^^^' ,
118
104
' 28 | }' ,
@@ -140,7 +126,7 @@ describe('TypeScript Vue Extension', () => {
140
126
'ERROR in src/component/LoggedIn.vue:27:29' ,
141
127
"TS2339: Property 'firstName' does not exist on type 'User'." ,
142
128
' 25 | const user: User = this.user;' ,
143
- ' 26 |' ,
129
+ ' 26 | ' ,
144
130
" > 27 | return user ? `${user.firstName} ${user.lastName}` : '';" ,
145
131
' | ^^^^^^^^^' ,
146
132
' 28 | }' ,
@@ -150,7 +136,7 @@ describe('TypeScript Vue Extension', () => {
150
136
[
151
137
'ERROR in src/model/User.ts:11:16' ,
152
138
"TS2339: Property 'firstName' does not exist on type 'User'." ,
153
- ' 9 |' ,
139
+ ' 9 | ' ,
154
140
' 10 | function getUserName(user: User): string {' ,
155
141
' > 11 | return [user.firstName, user.lastName]' ,
156
142
' | ^^^^^^^^^' ,
@@ -159,62 +145,6 @@ describe('TypeScript Vue Extension', () => {
159
145
' 14 | }' ,
160
146
] . join ( '\n' ) ,
161
147
] ) ;
162
-
163
- // fix the error
164
- await sandbox . patch (
165
- 'src/model/User.ts' ,
166
- ' lastName?: string;' ,
167
- [ ' firstName?: string;' , ' lastName?: string;' ] . join ( '\n' )
168
- ) ;
169
- await driver . waitForNoErrors ( ) ;
170
-
171
- if ( semver . satisfies ( '3.0.0' , vue ) ) {
172
- await sandbox . patch (
173
- 'src/component/Header.vue' ,
174
- 'defineProps({' ,
175
- [ 'let x: number = "1"' , 'defineProps({' ] . join ( '\n' )
176
- ) ;
177
-
178
- errors = await driver . waitForErrors ( ) ;
179
- expect ( errors ) . toEqual ( [
180
- [
181
- 'ERROR in src/component/Header.vue:6:5' ,
182
- "TS2322: Type '\"1\"' is not assignable to type 'number'." ,
183
- ' 4 |' ,
184
- ' 5 | <script setup lang="ts">' ,
185
- ' > 6 | let x: number = "1"' ,
186
- ' | ^' ,
187
- ' 7 | defineProps({' ,
188
- ' 8 | title: String,' ,
189
- ' 9 | });' ,
190
- ] . join ( '\n' ) ,
191
- ] ) ;
192
- // fix the issue
193
- await sandbox . patch ( 'src/component/Header.vue' , 'let x: number = "1"' , '' ) ;
194
- await driver . waitForNoErrors ( ) ;
195
-
196
- // introduce error in second <script>
197
- await sandbox . patch (
198
- 'src/component/Logo.vue' ,
199
- 'export default {' ,
200
- [ 'let x: number = "1";' , 'export default {' ] . join ( '\n' )
201
- ) ;
202
-
203
- errors = await driver . waitForErrors ( ) ;
204
- expect ( errors ) . toEqual ( [
205
- [
206
- 'ERROR in src/component/Logo.vue:15:5' ,
207
- "TS2322: Type '\"1\"' is not assignable to type 'number'." ,
208
- ' 13 |' ,
209
- ' 14 | <script lang="ts">' ,
210
- ' > 15 | let x: number = "1";' ,
211
- ' | ^' ,
212
- ' 16 | export default {' ,
213
- ' 17 | inheritAttrs: false,' ,
214
- ' 18 | customOptions: {}' ,
215
- ] . join ( '\n' ) ,
216
- ] ) ;
217
- }
218
148
}
219
149
) ;
220
150
} ) ;
0 commit comments