Skip to content

Commit 784a765

Browse files
committed
Fix microsoft#9173: clear out lib and types before creating a program in transpileModule
1 parent 7890fd5 commit 784a765

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/services/services.ts

+4
Original file line numberDiff line numberDiff line change
@@ -2001,6 +2001,10 @@ namespace ts {
20012001
// so pass --noLib to avoid reporting a file not found error.
20022002
options.noLib = true;
20032003

2004+
// Clear out the lib and types option as well
2005+
options.lib = undefined;
2006+
options.types = undefined;
2007+
20042008
// We are not doing a full typecheck, we are not resolving the whole context,
20052009
// so pass --noResolve to avoid reporting missing file errors.
20062010
options.noResolve = true;

tests/cases/unittests/transpile.ts

+18
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,24 @@ var x = 0;`,
304304
test("var x", { expectedOutput: `"use strict";\r\nvar x;\r\n`, options: { fileName: "http://somewhere/directory//directory2/file.ts" } });
305305
});
306306

307+
it("Support options with lib values", () => {
308+
const input = "const a = 10;";
309+
const output = `"use strict";\r\nvar a = 10;\r\n`;
310+
test(input, {
311+
expectedOutput: output,
312+
options: { compilerOptions: { lib: ["es6", "dom"], module: ModuleKind.CommonJS }, fileName: "input.js", reportDiagnostics: true }
313+
});
314+
});
315+
316+
it("Support options with types values", () => {
317+
const input = "const a = 10;";
318+
const output = `"use strict";\r\nvar a = 10;\r\n`;
319+
test(input, {
320+
expectedOutput: output,
321+
options: { compilerOptions: { types: ["jquery", "typescript"], module: ModuleKind.CommonJS }, fileName: "input.js", reportDiagnostics: true }
322+
});
323+
});
324+
307325
describe("String values for enums", () => {
308326
it("Accepts strings instead of enum values", () => {
309327
test(`export const x = 0`, {

0 commit comments

Comments
 (0)