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

This commit is contained in:
Mohamed Hegazy 2016-06-14 17:44:57 -07:00
parent 7890fd58b9
commit 784a76530c
2 changed files with 22 additions and 0 deletions

View file

@ -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;

View file

@ -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`, {