From d93e0d40967dee0a2383479b9d2b20ca82669978 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 10 Jul 2018 15:43:00 -0700 Subject: [PATCH] Add test for reporting errors from deep import. Test case for #24986 --- src/testRunner/unittests/tscWatchMode.ts | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/testRunner/unittests/tscWatchMode.ts b/src/testRunner/unittests/tscWatchMode.ts index 13361d13003..f962d736465 100644 --- a/src/testRunner/unittests/tscWatchMode.ts +++ b/src/testRunner/unittests/tscWatchMode.ts @@ -1270,6 +1270,46 @@ export default test;`; checkOutputErrorsIncremental(host, expectedErrors); } }); + + it("updates errors when deep import file changes", () => { + const currentDirectory = "/user/username/projects/myproject"; + const aFile: File = { + path: `${currentDirectory}/a.ts`, + content: `import {B} from './b'; +declare var console: any; +let b = new B(); +console.log(b.c.d);` + }; + const bFile: File = { + path: `${currentDirectory}/b.ts`, + content: `import {C} from './c'; +export class B +{ + c = new C(); +}` + }; + const cFile: File = { + path: `${currentDirectory}/c.ts`, + content: `export class C +{ + d = 1; +}` + }; + const config: File = { + path: `${currentDirectory}/tsconfig.json`, + content: `{}` + }; + const files = [aFile, bFile, cFile, config, libFile]; + const host = createWatchedSystem(files, { currentDirectory }); + const watch = createWatchOfConfigFile("tsconfig.json", host); + checkProgramActualFiles(watch(), [aFile.path, bFile.path, cFile.path, libFile.path]); + checkOutputErrorsInitial(host, emptyArray); + host.writeFile(cFile.path, cFile.content.replace("d", "d2")); + host.runQueuedTimeoutCallbacks(); + checkOutputErrorsIncremental(host, [ + getDiagnosticOfFileFromProgram(watch(), aFile.path, aFile.content.lastIndexOf("d"), 1, Diagnostics.Property_0_does_not_exist_on_type_1, "d", "C") + ]); + }); }); describe("tsc-watch emit with outFile or out setting", () => {