Skip to content

Fix #9173: clear out lib and types before creating a program in transpileModule #9174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions tests/cases/unittests/transpile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`, {
Expand Down