@@ -15,8 +15,8 @@ namespace ts.tscWatch {
1515 const host = createWatchedSystem ( files ) ;
1616 const watch = createWatchOfFilesAndCompilerOptions ( [ root . path ] , host , { module : ModuleKind . AMD } ) ;
1717
18- const f1IsNotModule = getDiagnosticOfFileFromProgram ( watch ( ) , root . path , root . content . indexOf ( '"f1"' ) , '"f1"' . length , Diagnostics . File_0_is_not_a_module , imported . path ) ;
19- const cannotFindFoo = getDiagnosticOfFileFromProgram ( watch ( ) , imported . path , imported . content . indexOf ( "foo" ) , "foo" . length , Diagnostics . Cannot_find_name_0 , "foo" ) ;
18+ const f1IsNotModule = getDiagnosticOfFileFromProgram ( watch . getCurrentProgram ( ) . getProgram ( ) , root . path , root . content . indexOf ( '"f1"' ) , '"f1"' . length , Diagnostics . File_0_is_not_a_module , imported . path ) ;
19+ const cannotFindFoo = getDiagnosticOfFileFromProgram ( watch . getCurrentProgram ( ) . getProgram ( ) , imported . path , imported . content . indexOf ( "foo" ) , "foo" . length , Diagnostics . Cannot_find_name_0 , "foo" ) ;
2020
2121 // ensure that imported file was found
2222 checkOutputErrorsInitial ( host , [ f1IsNotModule , cannotFindFoo ] ) ;
@@ -37,7 +37,7 @@ namespace ts.tscWatch {
3737 // ensure file has correct number of errors after edit
3838 checkOutputErrorsIncremental ( host , [
3939 f1IsNotModule ,
40- getDiagnosticOfFileFromProgram ( watch ( ) , root . path , newContent . indexOf ( "var x" ) + "var " . length , "x" . length , Diagnostics . Type_0_is_not_assignable_to_type_1 , 1 , "string" ) ,
40+ getDiagnosticOfFileFromProgram ( watch . getCurrentProgram ( ) . getProgram ( ) , root . path , newContent . indexOf ( "var x" ) + "var " . length , "x" . length , Diagnostics . Type_0_is_not_assignable_to_type_1 , 1 , "string" ) ,
4141 cannotFindFoo
4242 ] ) ;
4343 }
@@ -60,7 +60,7 @@ namespace ts.tscWatch {
6060
6161 // ensure file has correct number of errors after edit
6262 checkOutputErrorsIncremental ( host , [
63- getDiagnosticModuleNotFoundOfFile ( watch ( ) , root , "f2" )
63+ getDiagnosticModuleNotFoundOfFile ( watch . getCurrentProgram ( ) . getProgram ( ) , root , "f2" )
6464 ] ) ;
6565
6666 assert . isTrue ( fileExistsIsCalled ) ;
@@ -118,7 +118,7 @@ namespace ts.tscWatch {
118118
119119 assert . isTrue ( fileExistsCalledForBar , "'fileExists' should be called" ) ;
120120 checkOutputErrorsInitial ( host , [
121- getDiagnosticModuleNotFoundOfFile ( watch ( ) , root , "bar" )
121+ getDiagnosticModuleNotFoundOfFile ( watch . getCurrentProgram ( ) . getProgram ( ) , root , "bar" )
122122 ] ) ;
123123
124124 fileExistsCalledForBar = false ;
@@ -166,7 +166,7 @@ namespace ts.tscWatch {
166166 host . runQueuedTimeoutCallbacks ( ) ;
167167 assert . isTrue ( fileExistsCalledForBar , "'fileExists' should be called." ) ;
168168 checkOutputErrorsIncremental ( host , [
169- getDiagnosticModuleNotFoundOfFile ( watch ( ) , root , "bar" )
169+ getDiagnosticModuleNotFoundOfFile ( watch . getCurrentProgram ( ) . getProgram ( ) , root , "bar" )
170170 ] ) ;
171171
172172 fileExistsCalledForBar = false ;
@@ -391,6 +391,13 @@ declare namespace myapp {
391391 } ) ;
392392 sys . checkTimeoutQueueLengthAndRun ( 1 ) ;
393393 return "npm install ts-types" ;
394+ } ,
395+ ( sys , [ [ oldProgram , oldBuilderProgram ] ] , watchorSolution ) => {
396+ sys . checkTimeoutQueueLength ( 0 ) ;
397+ const newProgram = ( watchorSolution as Watch ) . getProgram ( ) ;
398+ assert . strictEqual ( newProgram , oldBuilderProgram , "No change so builder program should be same" ) ;
399+ assert . strictEqual ( newProgram . getProgram ( ) , oldProgram , "No change so program should be same" ) ;
400+ return "No change, just check program" ;
394401 }
395402 ]
396403 } ) ;
0 commit comments