@@ -9,6 +9,7 @@ namespace ts.tscWatch {
9
9
10
10
interface VerifyIncrementalWatchEmitInput {
11
11
files : ReadonlyArray < File > ;
12
+ optionsToExtend ?: CompilerOptions ;
12
13
expectedInitialEmit : ReadonlyArray < File > ;
13
14
expectedInitialErrors : ReadonlyArray < string > ;
14
15
modifyFs ?: ( host : WatchedSystem ) => void ;
@@ -32,9 +33,9 @@ namespace ts.tscWatch {
32
33
} ) ;
33
34
}
34
35
35
- function incrementalBuild ( configFile : string , host : WatchedSystem ) {
36
+ function incrementalBuild ( configFile : string , host : WatchedSystem , optionsToExtend ?: CompilerOptions ) {
36
37
const reportDiagnostic = createDiagnosticReporter ( host ) ;
37
- const config = parseConfigFileWithSystem ( configFile , { } , host , reportDiagnostic ) ;
38
+ const config = parseConfigFileWithSystem ( configFile , optionsToExtend || { } , host , reportDiagnostic ) ;
38
39
if ( config ) {
39
40
performIncrementalCompilation ( {
40
41
rootNames : config . fileNames ,
@@ -50,12 +51,14 @@ namespace ts.tscWatch {
50
51
51
52
interface VerifyIncrementalWatchEmitWorkerInput {
52
53
input : VerifyIncrementalWatchEmitInput ;
53
- emitAndReportErrors : ( configFile : string , host : WatchedSystem ) => { close ( ) : void ; } ;
54
+ emitAndReportErrors : ( configFile : string , host : WatchedSystem , optionsToExtend ?: CompilerOptions ) => { close ( ) : void ; } ;
54
55
verifyErrors : ( host : WatchedSystem , errors : ReadonlyArray < string > ) => void ;
55
56
}
56
57
function verifyIncrementalWatchEmitWorker ( {
57
58
input : {
58
- files, expectedInitialEmit, expectedInitialErrors, modifyFs, expectedIncrementalEmit, expectedIncrementalErrors
59
+ files, optionsToExtend,
60
+ expectedInitialEmit, expectedInitialErrors,
61
+ modifyFs, expectedIncrementalEmit, expectedIncrementalErrors
59
62
} ,
60
63
emitAndReportErrors,
61
64
verifyErrors
@@ -70,6 +73,7 @@ namespace ts.tscWatch {
70
73
} ;
71
74
verifyBuild ( {
72
75
host,
76
+ optionsToExtend,
73
77
writtenFiles,
74
78
emitAndReportErrors,
75
79
verifyErrors,
@@ -80,6 +84,7 @@ namespace ts.tscWatch {
80
84
modifyFs ( host ) ;
81
85
verifyBuild ( {
82
86
host,
87
+ optionsToExtend,
83
88
writtenFiles,
84
89
emitAndReportErrors,
85
90
verifyErrors,
@@ -91,15 +96,19 @@ namespace ts.tscWatch {
91
96
92
97
interface VerifyBuildWorker {
93
98
host : WatchedSystem ;
99
+ optionsToExtend ?: CompilerOptions ;
94
100
writtenFiles : Map < string > ;
95
101
emitAndReportErrors : VerifyIncrementalWatchEmitWorkerInput [ "emitAndReportErrors" ] ;
96
102
verifyErrors : VerifyIncrementalWatchEmitWorkerInput [ "verifyErrors" ] ;
97
103
expectedEmit : ReadonlyArray < File > ;
98
104
expectedErrors : ReadonlyArray < string > ;
99
105
}
100
- function verifyBuild ( { host, writtenFiles, emitAndReportErrors, verifyErrors, expectedEmit, expectedErrors } : VerifyBuildWorker ) {
106
+ function verifyBuild ( {
107
+ host, optionsToExtend, writtenFiles, emitAndReportErrors,
108
+ verifyErrors, expectedEmit, expectedErrors
109
+ } : VerifyBuildWorker ) {
101
110
writtenFiles . clear ( ) ;
102
- const result = emitAndReportErrors ( "tsconfig.json" , host ) ;
111
+ const result = emitAndReportErrors ( "tsconfig.json" , host , optionsToExtend ) ;
103
112
checkFileEmit ( writtenFiles , expectedEmit ) ;
104
113
verifyErrors ( host , expectedErrors ) ;
105
114
result . close ( ) ;
@@ -159,60 +168,69 @@ namespace ts.tscWatch {
159
168
content : "var y = 20;\n"
160
169
} ;
161
170
describe ( "own file emit without errors" , ( ) => {
162
- const modifiedFile2Content = file2 . content . replace ( "y" , "z" ) . replace ( "20" , "10" ) ;
163
- verifyIncrementalWatchEmit ( {
164
- files : [ libFile , file1 , file2 , configFile ] ,
165
- expectedInitialEmit : [
166
- file1Js ,
167
- file2Js ,
168
- {
169
- path : `${ project } /tsconfig.tsbuildinfo` ,
170
- content : getBuildInfoText ( {
171
- program : {
172
- fileInfos : {
173
- [ libFilePath ] : libFileInfo ,
174
- [ file1Path ] : getFileInfo ( file1 . content ) ,
175
- [ file2Path ] : getFileInfo ( file2 . content )
176
- } ,
177
- options : {
178
- incremental : true ,
179
- configFilePath : "./tsconfig.json"
180
- } ,
181
- referencedMap : { } ,
182
- exportedModulesMap : { } ,
183
- semanticDiagnosticsPerFile : [ libFilePath , file1Path , file2Path ]
184
- } ,
185
- version
186
- } )
187
- }
188
- ] ,
189
- expectedInitialErrors : emptyArray ,
190
- modifyFs : host => host . writeFile ( file2 . path , modifiedFile2Content ) ,
191
- expectedIncrementalEmit : [
192
- file1Js ,
193
- { path : file2Js . path , content : file2Js . content . replace ( "y" , "z" ) . replace ( "20" , "10" ) } ,
194
- {
195
- path : `${ project } /tsconfig.tsbuildinfo` ,
196
- content : getBuildInfoText ( {
197
- program : {
198
- fileInfos : {
199
- [ libFilePath ] : libFileInfo ,
200
- [ file1Path ] : getFileInfo ( file1 . content ) ,
201
- [ file2Path ] : getFileInfo ( modifiedFile2Content )
171
+ function verify ( optionsToExtend ?: CompilerOptions , expectedBuildinfoOptions ?: CompilerOptions ) {
172
+ const modifiedFile2Content = file2 . content . replace ( "y" , "z" ) . replace ( "20" , "10" ) ;
173
+ verifyIncrementalWatchEmit ( {
174
+ files : [ libFile , file1 , file2 , configFile ] ,
175
+ optionsToExtend,
176
+ expectedInitialEmit : [
177
+ file1Js ,
178
+ file2Js ,
179
+ {
180
+ path : `${ project } /tsconfig.tsbuildinfo` ,
181
+ content : getBuildInfoText ( {
182
+ program : {
183
+ fileInfos : {
184
+ [ libFilePath ] : libFileInfo ,
185
+ [ file1Path ] : getFileInfo ( file1 . content ) ,
186
+ [ file2Path ] : getFileInfo ( file2 . content )
187
+ } ,
188
+ options : {
189
+ incremental : true ,
190
+ ...expectedBuildinfoOptions ,
191
+ configFilePath : "./tsconfig.json"
192
+ } ,
193
+ referencedMap : { } ,
194
+ exportedModulesMap : { } ,
195
+ semanticDiagnosticsPerFile : [ libFilePath , file1Path , file2Path ]
202
196
} ,
203
- options : {
204
- incremental : true ,
205
- configFilePath : "./tsconfig.json"
197
+ version
198
+ } )
199
+ }
200
+ ] ,
201
+ expectedInitialErrors : emptyArray ,
202
+ modifyFs : host => host . writeFile ( file2 . path , modifiedFile2Content ) ,
203
+ expectedIncrementalEmit : [
204
+ file1Js ,
205
+ { path : file2Js . path , content : file2Js . content . replace ( "y" , "z" ) . replace ( "20" , "10" ) } ,
206
+ {
207
+ path : `${ project } /tsconfig.tsbuildinfo` ,
208
+ content : getBuildInfoText ( {
209
+ program : {
210
+ fileInfos : {
211
+ [ libFilePath ] : libFileInfo ,
212
+ [ file1Path ] : getFileInfo ( file1 . content ) ,
213
+ [ file2Path ] : getFileInfo ( modifiedFile2Content )
214
+ } ,
215
+ options : {
216
+ incremental : true ,
217
+ ...expectedBuildinfoOptions ,
218
+ configFilePath : "./tsconfig.json"
219
+ } ,
220
+ referencedMap : { } ,
221
+ exportedModulesMap : { } ,
222
+ semanticDiagnosticsPerFile : [ libFilePath , file1Path , file2Path ]
206
223
} ,
207
- referencedMap : { } ,
208
- exportedModulesMap : { } ,
209
- semanticDiagnosticsPerFile : [ libFilePath , file1Path , file2Path ]
210
- } ,
211
- version
212
- } )
213
- }
214
- ] ,
215
- expectedIncrementalErrors : emptyArray ,
224
+ version
225
+ } )
226
+ }
227
+ ] ,
228
+ expectedIncrementalErrors : emptyArray ,
229
+ } ) ;
230
+ }
231
+ verify ( ) ;
232
+ describe ( "with commandline parameters that are not relative" , ( ) => {
233
+ verify ( { project : "tsconfig.json" } , { project : "./tsconfig.json" } ) ;
216
234
} ) ;
217
235
} ) ;
218
236
@@ -337,6 +355,7 @@ namespace ts.tscWatch {
337
355
expectedInitialErrors : emptyArray
338
356
} ) ;
339
357
} ) ;
358
+
340
359
} ) ;
341
360
342
361
describe ( "module compilation" , ( ) => {
0 commit comments