Skip to content

Commit d93e0d4

Browse files
committed
Add test for reporting errors from deep import.
Test case for #24986
1 parent 527093c commit d93e0d4

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/testRunner/unittests/tscWatchMode.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,46 @@ export default test;`;
12701270
checkOutputErrorsIncremental(host, expectedErrors);
12711271
}
12721272
});
1273+
1274+
it("updates errors when deep import file changes", () => {
1275+
const currentDirectory = "/user/username/projects/myproject";
1276+
const aFile: File = {
1277+
path: `${currentDirectory}/a.ts`,
1278+
content: `import {B} from './b';
1279+
declare var console: any;
1280+
let b = new B();
1281+
console.log(b.c.d);`
1282+
};
1283+
const bFile: File = {
1284+
path: `${currentDirectory}/b.ts`,
1285+
content: `import {C} from './c';
1286+
export class B
1287+
{
1288+
c = new C();
1289+
}`
1290+
};
1291+
const cFile: File = {
1292+
path: `${currentDirectory}/c.ts`,
1293+
content: `export class C
1294+
{
1295+
d = 1;
1296+
}`
1297+
};
1298+
const config: File = {
1299+
path: `${currentDirectory}/tsconfig.json`,
1300+
content: `{}`
1301+
};
1302+
const files = [aFile, bFile, cFile, config, libFile];
1303+
const host = createWatchedSystem(files, { currentDirectory });
1304+
const watch = createWatchOfConfigFile("tsconfig.json", host);
1305+
checkProgramActualFiles(watch(), [aFile.path, bFile.path, cFile.path, libFile.path]);
1306+
checkOutputErrorsInitial(host, emptyArray);
1307+
host.writeFile(cFile.path, cFile.content.replace("d", "d2"));
1308+
host.runQueuedTimeoutCallbacks();
1309+
checkOutputErrorsIncremental(host, [
1310+
getDiagnosticOfFileFromProgram(watch(), aFile.path, aFile.content.lastIndexOf("d"), 1, Diagnostics.Property_0_does_not_exist_on_type_1, "d", "C")
1311+
]);
1312+
});
12731313
});
12741314

12751315
describe("tsc-watch emit with outFile or out setting", () => {

0 commit comments

Comments
 (0)