77 WEBPACK_DEV_SERVER_VERSION ,
88} from './sandbox/WebpackDevServerDriver' ;
99import { FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION } from './sandbox/Plugin' ;
10- import semver from 'semver/preload' ;
1110
1211describe ( 'TypeScript Vue Extension' , ( ) => {
1312 let sandbox : Sandbox ;
@@ -30,23 +29,21 @@ describe('TypeScript Vue Extension', () => {
3029 typescript : '^3.8.0' ,
3130 tsloader : '^7.0.0' ,
3231 vueloader : '^15.8.3' ,
33- vue : '^2.0.0 ' ,
32+ vue : '^2.6.11 ' ,
3433 compiler : 'vue-template-compiler' ,
35- qrcodevue : '^1.7.0' ,
3634 } ,
3735 {
3836 async : true ,
3937 typescript : '^3.8.0' ,
4038 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 ' ,
4341 compiler : '@vue/compiler-sfc' ,
44- qrcodevue : '^3.0.0' ,
4542 } ,
4643 ] ) (
4744 '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 ( [
5047 await readFixture ( join ( __dirname , 'fixtures/environment/typescript-vue.fixture' ) , {
5148 FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION : JSON . stringify (
5249 FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION
@@ -59,23 +56,12 @@ describe('TypeScript Vue Extension', () => {
5956 VUE_LOADER_VERSION : JSON . stringify ( vueloader ) ,
6057 VUE_VERSION : JSON . stringify ( vue ) ,
6158 VUE_COMPILER : JSON . stringify ( compiler ) ,
62- QRCODE_VUE_VERSION : JSON . stringify ( qrcodevue ) ,
6359 ASYNC : JSON . stringify ( async ) ,
6460 } ) ,
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+ ] ) ;
7763
78- if ( semver . satisfies ( '2.0.0' , vue ) ) {
64+ if ( vue === '^2.6.11' ) {
7965 await sandbox . write (
8066 'src/vue-shim.d.ts' ,
8167 [
@@ -85,7 +71,7 @@ describe('TypeScript Vue Extension', () => {
8571 '}' ,
8672 ] . join ( '\n' )
8773 ) ;
88- } else if ( semver . satisfies ( '3.0.0' , vue ) ) {
74+ } else {
8975 await sandbox . write ( 'src/vue-shim.d.ts' , 'declare module "*.vue";' ) ;
9076 }
9177
@@ -112,7 +98,7 @@ describe('TypeScript Vue Extension', () => {
11298 'ERROR in src/component/LoggedIn.vue:27:21' ,
11399 "TS2304: Cannot find name 'getUserName'." ,
114100 ' 25 | const user: User = this.user;' ,
115- ' 26 |' ,
101+ ' 26 | ' ,
116102 " > 27 | return user ? getUserName(user) : '';" ,
117103 ' | ^^^^^^^^^^^' ,
118104 ' 28 | }' ,
@@ -140,7 +126,7 @@ describe('TypeScript Vue Extension', () => {
140126 'ERROR in src/component/LoggedIn.vue:27:29' ,
141127 "TS2339: Property 'firstName' does not exist on type 'User'." ,
142128 ' 25 | const user: User = this.user;' ,
143- ' 26 |' ,
129+ ' 26 | ' ,
144130 " > 27 | return user ? `${user.firstName} ${user.lastName}` : '';" ,
145131 ' | ^^^^^^^^^' ,
146132 ' 28 | }' ,
@@ -150,7 +136,7 @@ describe('TypeScript Vue Extension', () => {
150136 [
151137 'ERROR in src/model/User.ts:11:16' ,
152138 "TS2339: Property 'firstName' does not exist on type 'User'." ,
153- ' 9 |' ,
139+ ' 9 | ' ,
154140 ' 10 | function getUserName(user: User): string {' ,
155141 ' > 11 | return [user.firstName, user.lastName]' ,
156142 ' | ^^^^^^^^^' ,
@@ -159,62 +145,6 @@ describe('TypeScript Vue Extension', () => {
159145 ' 14 | }' ,
160146 ] . join ( '\n' ) ,
161147 ] ) ;
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- }
218148 }
219149 ) ;
220150} ) ;
0 commit comments