Skip to content

Ports #6789 into release-1.8 #6791

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
Feb 1, 2016
Merged
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
2 changes: 1 addition & 1 deletion src/compiler/program.ts
Original file line number Diff line number Diff line change
@@ -1359,7 +1359,7 @@ namespace ts {
}

// If the emit is enabled make sure that every output file is unique and not overwriting any of the input files
if (!options.noEmit) {
if (!options.noEmit && !options.suppressOutputPathCheck) {
const emitHost = getEmitHost();
const emitFilesSeen = createFileMap<boolean>(!host.useCaseSensitiveFileNames() ? key => key.toLocaleLowerCase() : undefined);
forEachExpectedEmitFile(emitHost, (emitFileNames, sourceFiles, isBundledEmit) => {
2 changes: 2 additions & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
@@ -2438,6 +2438,8 @@ namespace ts {

// Skip checking lib.d.ts to help speed up tests.
/* @internal */ skipDefaultLibCheck?: boolean;
// Do not perform validation of output file name in transpile scenarios
/* @internal */ suppressOutputPathCheck?: boolean;

[option: string]: string | number | boolean;
}
3 changes: 3 additions & 0 deletions src/services/services.ts
Original file line number Diff line number Diff line change
@@ -1875,6 +1875,9 @@ namespace ts {

options.isolatedModules = true;

// transpileModule does not write anything to disk so there is no need to verify that there are no conflicts between input and output paths.
options.suppressOutputPathCheck = true;

// Filename can be non-ts file.
options.allowNonTsExtensions = true;

9 changes: 9 additions & 0 deletions tests/cases/unittests/transpile.ts
Original file line number Diff line number Diff line change
@@ -291,5 +291,14 @@ var x = 0;`,
options: { compilerOptions: { jsx: JsxEmit.React, newLine: NewLineKind.LineFeed } }
})
});
it("transpile .js files", () => {
const input = "const a = 10;";
const output = `"use strict";\nvar a = 10;\n`;
test(input, {
expectedOutput: output,
options: { compilerOptions: { newLine: NewLineKind.LineFeed, module: ModuleKind.CommonJS }, fileName: "input.js", reportDiagnostics: true },
expectedDiagnosticCodes: []
});
})
});
}