@@ -1312,6 +1312,49 @@ export class B
1312
1312
// File a need not be rewritten
1313
1313
assert . equal ( host . getModifiedTime ( `${ currentDirectory } /a.js` ) , modifiedTimeOfAJs ) ;
1314
1314
} ) ;
1315
+
1316
+ it ( "updates errors when strictNullChecks changes" , ( ) => {
1317
+ const currentDirectory = "/user/username/projects/myproject" ;
1318
+ const aFile : File = {
1319
+ path : `${ currentDirectory } /a.ts` ,
1320
+ content : `declare function foo(): null | { hello: any };
1321
+ foo().hello`
1322
+ } ;
1323
+ const compilerOptions : CompilerOptions = {
1324
+ } ;
1325
+ const config : File = {
1326
+ path : `${ currentDirectory } /tsconfig.json` ,
1327
+ content : JSON . stringify ( { compilerOptions } )
1328
+ } ;
1329
+ const files = [ aFile , config , libFile ] ;
1330
+ const host = createWatchedSystem ( files , { currentDirectory } ) ;
1331
+ const watch = createWatchOfConfigFile ( "tsconfig.json" , host ) ;
1332
+ checkProgramActualFiles ( watch ( ) , [ aFile . path , libFile . path ] ) ;
1333
+ checkOutputErrorsInitial ( host , emptyArray ) ;
1334
+ const modifiedTimeOfAJs = host . getModifiedTime ( `${ currentDirectory } /a.js` ) ;
1335
+ compilerOptions . strictNullChecks = true ;
1336
+ host . writeFile ( config . path , JSON . stringify ( { compilerOptions } ) ) ;
1337
+ host . runQueuedTimeoutCallbacks ( ) ;
1338
+ const expectedStrictNullErrors = [
1339
+ getDiagnosticOfFileFromProgram ( watch ( ) , aFile . path , aFile . content . lastIndexOf ( "foo()" ) , 5 , Diagnostics . Object_is_possibly_null )
1340
+ ] ;
1341
+ checkOutputErrorsIncremental ( host , expectedStrictNullErrors ) ;
1342
+ // File a need not be rewritten
1343
+ assert . equal ( host . getModifiedTime ( `${ currentDirectory } /a.js` ) , modifiedTimeOfAJs ) ;
1344
+ compilerOptions . strict = true ;
1345
+ delete ( compilerOptions . strictNullChecks ) ;
1346
+ host . writeFile ( config . path , JSON . stringify ( { compilerOptions } ) ) ;
1347
+ host . runQueuedTimeoutCallbacks ( ) ;
1348
+ checkOutputErrorsIncremental ( host , expectedStrictNullErrors ) ;
1349
+ // File a need not be rewritten
1350
+ assert . equal ( host . getModifiedTime ( `${ currentDirectory } /a.js` ) , modifiedTimeOfAJs ) ;
1351
+ delete ( compilerOptions . strict ) ;
1352
+ host . writeFile ( config . path , JSON . stringify ( { compilerOptions } ) ) ;
1353
+ host . runQueuedTimeoutCallbacks ( ) ;
1354
+ checkOutputErrorsIncremental ( host , emptyArray ) ;
1355
+ // File a need not be rewritten
1356
+ assert . equal ( host . getModifiedTime ( `${ currentDirectory } /a.js` ) , modifiedTimeOfAJs ) ;
1357
+ } ) ;
1315
1358
} ) ;
1316
1359
1317
1360
describe ( "tsc-watch emit with outFile or out setting" , ( ) => {
0 commit comments