@@ -1281,7 +1281,59 @@ interface Document {
1281
1281
checkProgramActualFiles ( watch ( ) , [ aFile . path , bFile . path , libFile . path ] ) ;
1282
1282
}
1283
1283
} ) ;
1284
- } ) ;
1285
1284
1285
+ it ( "reports errors correctly with isolatedModules" , ( ) => {
1286
+ const currentDirectory = "/user/username/projects/myproject" ;
1287
+ const aFile : File = {
1288
+ path : `${ currentDirectory } /a.ts` ,
1289
+ content : `export const a: string = "";`
1290
+ } ;
1291
+ const bFile : File = {
1292
+ path : `${ currentDirectory } /b.ts` ,
1293
+ content : `import { a } from "./a";
1294
+ const b: string = a;`
1295
+ } ;
1296
+ const configFile : File = {
1297
+ path : `${ currentDirectory } /tsconfig.json` ,
1298
+ content : JSON . stringify ( {
1299
+ compilerOptions : {
1300
+ isolatedModules : true
1301
+ }
1302
+ } )
1303
+ } ;
1304
+
1305
+ const files = [ aFile , bFile , libFile , configFile ] ;
1286
1306
1307
+ const host = createWatchedSystem ( files , { currentDirectory } ) ;
1308
+ const watch = createWatchOfConfigFile ( "tsconfig.json" , host ) ;
1309
+ verifyProgramFiles ( ) ;
1310
+ checkOutputErrorsInitial ( host , emptyArray ) ;
1311
+ assert . equal ( host . readFile ( `${ currentDirectory } /a.js` ) , `"use strict";
1312
+ exports.__esModule = true;
1313
+ exports.a = "";
1314
+ ` , "Contents of a.js" ) ;
1315
+ assert . equal ( host . readFile ( `${ currentDirectory } /b.js` ) , `"use strict";
1316
+ exports.__esModule = true;
1317
+ var a_1 = require("./a");
1318
+ var b = a_1.a;
1319
+ ` , "Contents of b.js" ) ;
1320
+ const modifiedTime = host . getModifiedTime ( `${ currentDirectory } /b.js` ) ;
1321
+
1322
+ host . writeFile ( aFile . path , `export const a: number = 1` ) ;
1323
+ host . runQueuedTimeoutCallbacks ( ) ;
1324
+ verifyProgramFiles ( ) ;
1325
+ checkOutputErrorsIncremental ( host , [
1326
+ getDiagnosticOfFileFromProgram ( watch ( ) , bFile . path , bFile . content . indexOf ( "b" ) , 1 , Diagnostics . Type_0_is_not_assignable_to_type_1 , "number" , "string" )
1327
+ ] ) ;
1328
+ assert . equal ( host . readFile ( `${ currentDirectory } /a.js` ) , `"use strict";
1329
+ exports.__esModule = true;
1330
+ exports.a = 1;
1331
+ ` , "Contents of a.js" ) ;
1332
+ assert . equal ( host . getModifiedTime ( `${ currentDirectory } /b.js` ) , modifiedTime , "Timestamp of b.js" ) ;
1333
+
1334
+ function verifyProgramFiles ( ) {
1335
+ checkProgramActualFiles ( watch ( ) , [ aFile . path , bFile . path , libFile . path ] ) ;
1336
+ }
1337
+ } ) ;
1338
+ } ) ;
1287
1339
}
0 commit comments