diff --git a/src/services/services.ts b/src/services/services.ts index 8bf6a572ec754..c20f95a56f2de 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2001,6 +2001,10 @@ namespace ts { // so pass --noLib to avoid reporting a file not found error. options.noLib = true; + // Clear out the lib and types option as well + options.lib = undefined; + options.types = undefined; + // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. options.noResolve = true; diff --git a/tests/cases/unittests/transpile.ts b/tests/cases/unittests/transpile.ts index a4b1416ed291a..cac44994420ce 100644 --- a/tests/cases/unittests/transpile.ts +++ b/tests/cases/unittests/transpile.ts @@ -304,6 +304,24 @@ var x = 0;`, test("var x", { expectedOutput: `"use strict";\r\nvar x;\r\n`, options: { fileName: "http://somewhere/directory//directory2/file.ts" } }); }); + it("Support options with lib values", () => { + const input = "const a = 10;"; + const output = `"use strict";\r\nvar a = 10;\r\n`; + test(input, { + expectedOutput: output, + options: { compilerOptions: { lib: ["es6", "dom"], module: ModuleKind.CommonJS }, fileName: "input.js", reportDiagnostics: true } + }); + }); + + it("Support options with types values", () => { + const input = "const a = 10;"; + const output = `"use strict";\r\nvar a = 10;\r\n`; + test(input, { + expectedOutput: output, + options: { compilerOptions: { types: ["jquery", "typescript"], module: ModuleKind.CommonJS }, fileName: "input.js", reportDiagnostics: true } + }); + }); + describe("String values for enums", () => { it("Accepts strings instead of enum values", () => { test(`export const x = 0`, {