@@ -8,100 +8,98 @@ import {
8
8
} from './sandbox/WebpackDevServerDriver' ;
9
9
10
10
describe ( 'TypeScript SolutionBuilder API' , ( ) => {
11
- describe ( 'semantic error' , ( ) => {
12
- let sandbox : Sandbox ;
11
+ let sandbox : Sandbox ;
13
12
14
- beforeAll ( async ( ) => {
15
- sandbox = await createSandbox ( ) ;
16
- } ) ;
13
+ beforeAll ( async ( ) => {
14
+ sandbox = await createSandbox ( ) ;
15
+ } ) ;
17
16
18
- beforeEach ( async ( ) => {
19
- await sandbox . reset ( ) ;
20
- } ) ;
17
+ beforeEach ( async ( ) => {
18
+ await sandbox . reset ( ) ;
19
+ } ) ;
21
20
22
- afterAll ( async ( ) => {
23
- await sandbox . cleanup ( ) ;
24
- } ) ;
21
+ afterAll ( async ( ) => {
22
+ await sandbox . cleanup ( ) ;
23
+ } ) ;
25
24
26
- it . each ( [ { async : false } , { async : true } ] ) (
27
- 'reports semantic error for %p' ,
28
- async ( { async } ) => {
29
- await sandbox . load (
30
- await readFixture ( join ( __dirname , 'fixtures/typescript-project-references.fixture' ) , {
31
- FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION : JSON . stringify (
32
- FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION
33
- ) ,
34
- TS_LOADER_VERSION : JSON . stringify ( '^7.0.1' ) ,
35
- TYPESCRIPT_VERSION : JSON . stringify ( '~3.8.0' ) ,
36
- WEBPACK_VERSION : JSON . stringify ( '^4.0.0' ) ,
37
- WEBPACK_CLI_VERSION : JSON . stringify ( WEBPACK_CLI_VERSION ) ,
38
- WEBPACK_DEV_SERVER_VERSION : JSON . stringify ( WEBPACK_DEV_SERVER_VERSION ) ,
39
- ASYNC : JSON . stringify ( async ) ,
40
- } )
41
- ) ;
25
+ it . each ( [ { async : false } , { async : true } ] ) (
26
+ 'reports semantic error for %p' ,
27
+ async ( { async } ) => {
28
+ await sandbox . load (
29
+ await readFixture ( join ( __dirname , 'fixtures/typescript-project-references.fixture' ) , {
30
+ FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION : JSON . stringify (
31
+ FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION
32
+ ) ,
33
+ TS_LOADER_VERSION : JSON . stringify ( '^7.0.1' ) ,
34
+ TYPESCRIPT_VERSION : JSON . stringify ( '~3.8.0' ) ,
35
+ WEBPACK_VERSION : JSON . stringify ( '^4.0.0' ) ,
36
+ WEBPACK_CLI_VERSION : JSON . stringify ( WEBPACK_CLI_VERSION ) ,
37
+ WEBPACK_DEV_SERVER_VERSION : JSON . stringify ( WEBPACK_DEV_SERVER_VERSION ) ,
38
+ ASYNC : JSON . stringify ( async ) ,
39
+ } )
40
+ ) ;
42
41
43
- const driver = createWebpackDevServerDriver (
44
- sandbox . spawn ( './node_modules/.bin/webpack-dev-server' ) ,
45
- async
46
- ) ;
47
- let errors : string [ ] ;
42
+ const driver = createWebpackDevServerDriver (
43
+ sandbox . spawn ( './node_modules/.bin/webpack-dev-server' ) ,
44
+ async
45
+ ) ;
46
+ let errors : string [ ] ;
48
47
49
- // initial compilation should be successful
50
- await driver . waitForNoErrors ( ) ;
48
+ // initial compilation should be successful
49
+ await driver . waitForNoErrors ( ) ;
51
50
52
- // create semantic error in shared package
53
- await sandbox . patch ( 'packages/shared/src/intersect.ts' , 'arrayB: T[] = []' , 'arrayB: T' ) ;
51
+ // create semantic error in shared package
52
+ await sandbox . patch ( 'packages/shared/src/intersect.ts' , 'arrayB: T[] = []' , 'arrayB: T' ) ;
54
53
55
- // this compilation should contain semantic error in the shared project
56
- // (there is also an error in the client project but as its dependency is not built, it will not be processed)
57
- errors = await driver . waitForErrors ( ) ;
58
- expect ( errors ) . toEqual ( [
59
- [
60
- 'ERROR in packages/shared/src/intersect.ts 2:41-49' ,
61
- "TS2339: Property 'includes' does not exist on type 'T'." ,
62
- ' 1 | function intersect<T>(arrayA: T[] = [], arrayB: T): T[] {' ,
63
- ' > 2 | return arrayA.filter((item) => arrayB.includes(item));' ,
64
- ' | ^^^^^^^^' ,
65
- ' 3 | }' ,
66
- ' 4 | ' ,
67
- ' 5 | export default intersect;' ,
68
- ] . join ( '\n' ) ,
69
- ] ) ;
54
+ // this compilation should contain semantic error in the shared project
55
+ // (there is also an error in the client project but as its dependency is not built, it will not be processed)
56
+ errors = await driver . waitForErrors ( ) ;
57
+ expect ( errors ) . toEqual ( [
58
+ [
59
+ 'ERROR in packages/shared/src/intersect.ts 2:41-49' ,
60
+ "TS2339: Property 'includes' does not exist on type 'T'." ,
61
+ ' 1 | function intersect<T>(arrayA: T[] = [], arrayB: T): T[] {' ,
62
+ ' > 2 | return arrayA.filter((item) => arrayB.includes(item));' ,
63
+ ' | ^^^^^^^^' ,
64
+ ' 3 | }' ,
65
+ ' 4 | ' ,
66
+ ' 5 | export default intersect;' ,
67
+ ] . join ( '\n' ) ,
68
+ ] ) ;
70
69
71
- // fix semantic error in the shared package
72
- await sandbox . patch (
73
- 'packages/shared/src/intersect.ts' ,
74
- 'return arrayA.filter((item) => arrayB.includes(item));' ,
75
- 'return arrayA.filter((item) => item && arrayB);'
76
- ) ;
70
+ // fix semantic error in the shared package
71
+ await sandbox . patch (
72
+ 'packages/shared/src/intersect.ts' ,
73
+ 'return arrayA.filter((item) => arrayB.includes(item));' ,
74
+ 'return arrayA.filter((item) => item && arrayB);'
75
+ ) ;
77
76
78
- // this compilation should contain semantic error in the client project
79
- errors = await driver . waitForErrors ( ) ;
80
- expect ( errors ) . toEqual ( [
81
- [
82
- 'ERROR in packages/client/src/index.ts 4:42-48' ,
83
- "TS2345: Argument of type 'T[]' is not assignable to parameter of type 'T'." ,
84
- " 'T[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'." ,
85
- ' 2 | ' ,
86
- ' 3 | function compute<T>(arrayA: T[], arrayB: T[]) {' ,
87
- ' > 4 | const intersection = intersect(arrayA, arrayB);' ,
88
- ' | ^^^^^^' ,
89
- ' 5 | const difference = subtract(arrayA, arrayB);' ,
90
- ' 6 | ' ,
91
- ' 7 | return {' ,
92
- ] . join ( '\n' ) ,
93
- ] ) ;
77
+ // this compilation should contain semantic error in the client project
78
+ errors = await driver . waitForErrors ( ) ;
79
+ expect ( errors ) . toEqual ( [
80
+ [
81
+ 'ERROR in packages/client/src/index.ts 4:42-48' ,
82
+ "TS2345: Argument of type 'T[]' is not assignable to parameter of type 'T'." ,
83
+ " 'T[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'." ,
84
+ ' 2 | ' ,
85
+ ' 3 | function compute<T>(arrayA: T[], arrayB: T[]) {' ,
86
+ ' > 4 | const intersection = intersect(arrayA, arrayB);' ,
87
+ ' | ^^^^^^' ,
88
+ ' 5 | const difference = subtract(arrayA, arrayB);' ,
89
+ ' 6 | ' ,
90
+ ' 7 | return {' ,
91
+ ] . join ( '\n' ) ,
92
+ ] ) ;
94
93
95
- // fix semantic error in the client package
96
- await sandbox . patch (
97
- 'packages/client/src/index.ts' ,
98
- 'const intersection = intersect(arrayA, arrayB);' ,
99
- 'const intersection = intersect(arrayA, arrayB[0]);'
100
- ) ;
94
+ // fix semantic error in the client package
95
+ await sandbox . patch (
96
+ 'packages/client/src/index.ts' ,
97
+ 'const intersection = intersect(arrayA, arrayB);' ,
98
+ 'const intersection = intersect(arrayA, arrayB[0]);'
99
+ ) ;
101
100
102
- // this compilation should be successful
103
- await driver . waitForNoErrors ( ) ;
104
- }
105
- ) ;
106
- } ) ;
101
+ // this compilation should be successful
102
+ await driver . waitForNoErrors ( ) ;
103
+ }
104
+ ) ;
107
105
} ) ;
0 commit comments