Skip to content

Commit d280b1b

Browse files
committed
Merge pull request #7999 from Microsoft/fixHostOptionality
fix issue with optionality of CompilerHost
2 parents ac6224d + 1a85c5f commit d280b1b

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/compiler/program.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -959,15 +959,16 @@ namespace ts {
959959

960960
let resolvedTypeReferenceDirectives: Map<ResolvedTypeReferenceDirective> = {};
961961
let fileProcessingDiagnostics = createDiagnosticCollection();
962-
let skipDefaultLib = options.noLib;
963-
const programDiagnostics = createDiagnosticCollection();
964-
const currentDirectory = host.getCurrentDirectory();
965-
const supportedExtensions = getSupportedExtensions(options);
966962

967963
const start = new Date().getTime();
968964

969965
host = host || createCompilerHost(options);
970966

967+
let skipDefaultLib = options.noLib;
968+
const programDiagnostics = createDiagnosticCollection();
969+
const currentDirectory = host.getCurrentDirectory();
970+
const supportedExtensions = getSupportedExtensions(options);
971+
971972
// Map storing if there is emit blocking diagnostics for given input
972973
const hasEmitBlockingDiagnostics = createFileMap<boolean>(getCanonicalFileName);
973974

tests/cases/unittests/reuseProgramStructure.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,5 +368,11 @@ module ts {
368368
assert.isTrue(!program_3.structureIsReused);
369369
checkResolvedTypeDirectivesCache(program_1, "/a.ts", { "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } });
370370
});
371-
})
371+
});
372+
373+
describe("host is optional", () => {
374+
it("should work if host is not provided", () => {
375+
createProgram([], {});
376+
})
377+
});
372378
}

0 commit comments

Comments
 (0)