From 1a85c5f54c9ce2689f2a9aa40e77d567939914c8 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Sun, 10 Apr 2016 20:42:22 -0700 Subject: [PATCH] fix issue with optionality of CompilerHost --- src/compiler/program.ts | 9 +++++---- tests/cases/unittests/reuseProgramStructure.ts | 8 +++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 58ae0e3faf963..4c0598a2fc9db 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -959,15 +959,16 @@ namespace ts { let resolvedTypeReferenceDirectives: Map = {}; let fileProcessingDiagnostics = createDiagnosticCollection(); - let skipDefaultLib = options.noLib; - const programDiagnostics = createDiagnosticCollection(); - const currentDirectory = host.getCurrentDirectory(); - const supportedExtensions = getSupportedExtensions(options); const start = new Date().getTime(); host = host || createCompilerHost(options); + let skipDefaultLib = options.noLib; + const programDiagnostics = createDiagnosticCollection(); + const currentDirectory = host.getCurrentDirectory(); + const supportedExtensions = getSupportedExtensions(options); + // Map storing if there is emit blocking diagnostics for given input const hasEmitBlockingDiagnostics = createFileMap(getCanonicalFileName); diff --git a/tests/cases/unittests/reuseProgramStructure.ts b/tests/cases/unittests/reuseProgramStructure.ts index 036a58e0c99bd..61d5d56ca2c2a 100644 --- a/tests/cases/unittests/reuseProgramStructure.ts +++ b/tests/cases/unittests/reuseProgramStructure.ts @@ -368,5 +368,11 @@ module ts { assert.isTrue(!program_3.structureIsReused); checkResolvedTypeDirectivesCache(program_1, "/a.ts", { "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } }); }); - }) + }); + + describe("host is optional", () => { + it("should work if host is not provided", () => { + createProgram([], {}); + }) + }); } \ No newline at end of file