@@ -9,6 +9,7 @@ namespace ts.tscWatch {
99
1010 interface VerifyIncrementalWatchEmitInput {
1111 files : ReadonlyArray < File > ;
12+ optionsToExtend ?: CompilerOptions ;
1213 expectedInitialEmit : ReadonlyArray < File > ;
1314 expectedInitialErrors : ReadonlyArray < string > ;
1415 modifyFs ?: ( host : WatchedSystem ) => void ;
@@ -32,9 +33,9 @@ namespace ts.tscWatch {
3233 } ) ;
3334 }
3435
35- function incrementalBuild ( configFile : string , host : WatchedSystem ) {
36+ function incrementalBuild ( configFile : string , host : WatchedSystem , optionsToExtend ?: CompilerOptions ) {
3637 const reportDiagnostic = createDiagnosticReporter ( host ) ;
37- const config = parseConfigFileWithSystem ( configFile , { } , host , reportDiagnostic ) ;
38+ const config = parseConfigFileWithSystem ( configFile , optionsToExtend || { } , host , reportDiagnostic ) ;
3839 if ( config ) {
3940 performIncrementalCompilation ( {
4041 rootNames : config . fileNames ,
@@ -50,12 +51,14 @@ namespace ts.tscWatch {
5051
5152 interface VerifyIncrementalWatchEmitWorkerInput {
5253 input : VerifyIncrementalWatchEmitInput ;
53- emitAndReportErrors : ( configFile : string , host : WatchedSystem ) => { close ( ) : void ; } ;
54+ emitAndReportErrors : ( configFile : string , host : WatchedSystem , optionsToExtend ?: CompilerOptions ) => { close ( ) : void ; } ;
5455 verifyErrors : ( host : WatchedSystem , errors : ReadonlyArray < string > ) => void ;
5556 }
5657 function verifyIncrementalWatchEmitWorker ( {
5758 input : {
58- files, expectedInitialEmit, expectedInitialErrors, modifyFs, expectedIncrementalEmit, expectedIncrementalErrors
59+ files, optionsToExtend,
60+ expectedInitialEmit, expectedInitialErrors,
61+ modifyFs, expectedIncrementalEmit, expectedIncrementalErrors
5962 } ,
6063 emitAndReportErrors,
6164 verifyErrors
@@ -70,6 +73,7 @@ namespace ts.tscWatch {
7073 } ;
7174 verifyBuild ( {
7275 host,
76+ optionsToExtend,
7377 writtenFiles,
7478 emitAndReportErrors,
7579 verifyErrors,
@@ -80,6 +84,7 @@ namespace ts.tscWatch {
8084 modifyFs ( host ) ;
8185 verifyBuild ( {
8286 host,
87+ optionsToExtend,
8388 writtenFiles,
8489 emitAndReportErrors,
8590 verifyErrors,
@@ -91,15 +96,19 @@ namespace ts.tscWatch {
9196
9297 interface VerifyBuildWorker {
9398 host : WatchedSystem ;
99+ optionsToExtend ?: CompilerOptions ;
94100 writtenFiles : Map < string > ;
95101 emitAndReportErrors : VerifyIncrementalWatchEmitWorkerInput [ "emitAndReportErrors" ] ;
96102 verifyErrors : VerifyIncrementalWatchEmitWorkerInput [ "verifyErrors" ] ;
97103 expectedEmit : ReadonlyArray < File > ;
98104 expectedErrors : ReadonlyArray < string > ;
99105 }
100- function verifyBuild ( { host, writtenFiles, emitAndReportErrors, verifyErrors, expectedEmit, expectedErrors } : VerifyBuildWorker ) {
106+ function verifyBuild ( {
107+ host, optionsToExtend, writtenFiles, emitAndReportErrors,
108+ verifyErrors, expectedEmit, expectedErrors
109+ } : VerifyBuildWorker ) {
101110 writtenFiles . clear ( ) ;
102- const result = emitAndReportErrors ( "tsconfig.json" , host ) ;
111+ const result = emitAndReportErrors ( "tsconfig.json" , host , optionsToExtend ) ;
103112 checkFileEmit ( writtenFiles , expectedEmit ) ;
104113 verifyErrors ( host , expectedErrors ) ;
105114 result . close ( ) ;
@@ -159,60 +168,69 @@ namespace ts.tscWatch {
159168 content : "var y = 20;\n"
160169 } ;
161170 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 ]
202196 } ,
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 ]
206223 } ,
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" } ) ;
216234 } ) ;
217235 } ) ;
218236
@@ -337,6 +355,7 @@ namespace ts.tscWatch {
337355 expectedInitialErrors : emptyArray
338356 } ) ;
339357 } ) ;
358+
340359 } ) ;
341360
342361 describe ( "module compilation" , ( ) => {
0 commit comments