@@ -15,9 +15,35 @@ namespace ts.tscWatch {
15
15
expectedIncrementalEmit ?: ReadonlyArray < File > ;
16
16
expectedIncrementalErrors ?: ReadonlyArray < string > ;
17
17
}
18
- function verifyIncrementalWatchEmit ( {
19
- files, expectedInitialEmit, expectedInitialErrors, modifyFs, expectedIncrementalEmit, expectedIncrementalErrors
20
- } : VerifyIncrementalWatchEmitInput ) {
18
+ function verifyIncrementalWatchEmit ( input : VerifyIncrementalWatchEmitInput ) {
19
+ it ( "with tsc --w" , ( ) => {
20
+ verifyIncrementalWatchEmitWorker ( {
21
+ input,
22
+ emitAndReportErrors : createWatchOfConfigFile ,
23
+ verifyErrors : checkOutputErrorsInitial
24
+ } ) ;
25
+ } ) ;
26
+ it ( "with tsc" , ( ) => {
27
+ verifyIncrementalWatchEmitWorker ( {
28
+ input,
29
+ emitAndReportErrors : ,
30
+ verifyErrors
31
+ } ) ;
32
+ } ) ;
33
+ }
34
+
35
+ interface VerifyIncrementalWatchEmitWorkerInput {
36
+ input : VerifyIncrementalWatchEmitInput ;
37
+ emitAndReportErrors : ( configFile : string , host : WatchedSystem ) => { close ( ) : void ; } ;
38
+ verifyErrors : ( host : WatchedSystem , errors : ReadonlyArray < string > ) => void ;
39
+ }
40
+ function verifyIncrementalWatchEmitWorker ( {
41
+ input : {
42
+ files, expectedInitialEmit, expectedInitialErrors, modifyFs, expectedIncrementalEmit, expectedIncrementalErrors
43
+ } ,
44
+ emitAndReportErrors,
45
+ verifyErrors
46
+ } : VerifyIncrementalWatchEmitWorkerInput ) {
21
47
const host = createWatchedSystem ( files , { currentDirectory : project } ) ;
22
48
const originalWriteFile = host . writeFile ;
23
49
const writtenFiles = createMap < string > ( ) ;
@@ -26,18 +52,40 @@ namespace ts.tscWatch {
26
52
writtenFiles . set ( path , content ) ;
27
53
originalWriteFile . call ( host , path , content ) ;
28
54
} ;
29
- verifyWatch ( host , writtenFiles , expectedInitialEmit , expectedInitialErrors ) ;
55
+ verifyBuild ( {
56
+ host,
57
+ writtenFiles,
58
+ emitAndReportErrors,
59
+ verifyErrors,
60
+ expectedEmit : expectedInitialEmit ,
61
+ expectedErrors : expectedInitialErrors
62
+ } ) ;
30
63
if ( modifyFs ) {
31
64
modifyFs ( host ) ;
32
- verifyWatch ( host , writtenFiles , Debug . assertDefined ( expectedIncrementalEmit ) , Debug . assertDefined ( expectedIncrementalErrors ) ) ;
65
+ verifyBuild ( {
66
+ host,
67
+ writtenFiles,
68
+ emitAndReportErrors,
69
+ verifyErrors,
70
+ expectedEmit : Debug . assertDefined ( expectedIncrementalEmit ) ,
71
+ expectedErrors : Debug . assertDefined ( expectedIncrementalErrors )
72
+ } ) ;
33
73
}
34
74
}
35
75
36
- function verifyWatch ( host : WatchedSystem , writtenFiles : Map < string > , expectedEmit : ReadonlyArray < File > , expectedErrors : ReadonlyArray < string > ) {
76
+ interface VerifyBuildWorker {
77
+ host : WatchedSystem ;
78
+ writtenFiles : Map < string > ;
79
+ emitAndReportErrors : VerifyIncrementalWatchEmitWorkerInput [ "emitAndReportErrors" ] ;
80
+ verifyErrors : VerifyIncrementalWatchEmitWorkerInput [ "verifyErrors" ] ;
81
+ expectedEmit : ReadonlyArray < File > ;
82
+ expectedErrors : ReadonlyArray < string > ;
83
+ }
84
+ function verifyBuild ( { host, writtenFiles, emitAndReportErrors, verifyErrors, expectedEmit, expectedErrors } : VerifyBuildWorker ) {
37
85
writtenFiles . clear ( ) ;
38
- const watch = createWatchOfConfigFile ( "tsconfig.json" , host ) ;
86
+ const watch = emitAndReportErrors ( "tsconfig.json" , host ) ;
39
87
checkFileEmit ( writtenFiles , expectedEmit ) ;
40
- checkOutputErrorsInitial ( host , expectedErrors ) ;
88
+ verifyErrors ( host , expectedErrors ) ;
41
89
watch . close ( ) ;
42
90
}
43
91
@@ -73,7 +121,7 @@ namespace ts.tscWatch {
73
121
content : "var y = 20;\n"
74
122
} ;
75
123
76
- it ( "own file emit without errors" , ( ) => {
124
+ describe ( "own file emit without errors" , ( ) => {
77
125
const modifiedFile2Content = file2 . content . replace ( "y" , "z" ) . replace ( "20" , "10" ) ;
78
126
verifyIncrementalWatchEmit ( {
79
127
files : [ libFile , file1 , file2 , configFile ] ,
@@ -125,7 +173,7 @@ namespace ts.tscWatch {
125
173
} ) ;
126
174
} ) ;
127
175
128
- it ( "own file emit with errors" , ( ) => {
176
+ describe ( "own file emit with errors" , ( ) => {
129
177
const fileModified : File = {
130
178
path : file2 . path ,
131
179
content : `const y: string = 20;`
@@ -208,7 +256,7 @@ namespace ts.tscWatch {
208
256
} ) ;
209
257
} ) ;
210
258
211
- it ( "with --out" , ( ) => {
259
+ describe ( "with --out" , ( ) => {
212
260
const config : File = {
213
261
path : configFile . path ,
214
262
content : JSON . stringify ( { compilerOptions : { incremental : true , outFile : "out.js" } } )
@@ -279,7 +327,7 @@ namespace ts.tscWatch {
279
327
content : JSON . stringify ( { compilerOptions : { incremental : true , module : "amd" } } )
280
328
} ;
281
329
282
- it ( "own file emit without errors" , ( ) => {
330
+ describe ( "own file emit without errors" , ( ) => {
283
331
const modifiedFile2Content = file2 . content . replace ( "y" , "z" ) . replace ( "20" , "10" ) ;
284
332
verifyIncrementalWatchEmit ( {
285
333
files : [ libFile , file1 , file2 , config ] ,
@@ -330,7 +378,7 @@ namespace ts.tscWatch {
330
378
} ) ;
331
379
} ) ;
332
380
333
- it ( "own file emit with errors" , ( ) => {
381
+ describe ( "own file emit with errors" , ( ) => {
334
382
const fileModified : File = {
335
383
path : file2 . path ,
336
384
content : `export const y: string = 20;`
@@ -412,7 +460,7 @@ namespace ts.tscWatch {
412
460
} ) ;
413
461
} ) ;
414
462
415
- it ( "with --out" , ( ) => {
463
+ describe ( "with --out" , ( ) => {
416
464
const config : File = {
417
465
path : configFile . path ,
418
466
content : JSON . stringify ( { compilerOptions : { incremental : true , module : "amd" , outFile : "out.js" } } )
0 commit comments