Skip to content

Disallow --module with --out #4918

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

Closed
wants to merge 4 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) {
file(outFile, prereqs, function() {
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
var options = "--module commonjs --noImplicitAny --noEmitOnError";
var options = "--noImplicitAny --noEmitOnError";

// Keep comments when specifically requested
// or when in debug mode.
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,10 @@
"category": "Error",
"code": 5054
},
"Option '{0}' cannot be utilized alongside --module or with ES6 modules.": {
"category": "Error",
"code": 5055
},

"Concatenate and emit output to single file.": {
"category": "Message",
Expand Down
8 changes: 6 additions & 2 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -862,8 +862,8 @@ namespace ts {
const importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]);
if (importedFile && resolution.isExternalLibraryImport) {
if (!isExternalModule(importedFile)) {
let start = getTokenPosOfNode(file.imports[i], file)
fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
let start = getTokenPosOfNode(file.imports[i], file)
fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
}
else if (!fileExtensionIs(importedFile.fileName, ".d.ts")) {
let start = getTokenPosOfNode(file.imports[i], file)
Expand Down Expand Up @@ -1022,6 +1022,10 @@ namespace ts {
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
}

if (outFile && ((firstExternalModuleSourceFile && languageVersion >= ScriptTarget.ES6) || options.module)) {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_utilized_alongside_module_or_with_ES6_modules, options.out ? "out" : "outFile"));
}

// Cannot specify module gen target of es6 when below es6
if (options.module === ModuleKind.ES6 && languageVersion < ScriptTarget.ES6) {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower));
Expand Down
3 changes: 0 additions & 3 deletions src/harness/projectsRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ interface ProjectRunnerTestCase {
scenario: string;
projectRoot: string; // project where it lives - this also is the current directory when compiling
inputFiles: string[]; // list of input files to be given to program
out?: string; // --out
outDir?: string; // --outDir
sourceMap?: boolean; // --map
mapRoot?: string; // --mapRoot
Expand Down Expand Up @@ -158,7 +157,6 @@ class ProjectRunner extends RunnerBase {
return {
declaration: !!testCase.declaration,
sourceMap: !!testCase.sourceMap,
outFile: testCase.out,
outDir: testCase.outDir,
mapRoot: testCase.resolveMapRoot && testCase.mapRoot ? Harness.IO.resolvePath(testCase.mapRoot) : testCase.mapRoot,
sourceRoot: testCase.resolveSourceRoot && testCase.sourceRoot ? Harness.IO.resolvePath(testCase.sourceRoot) : testCase.sourceRoot,
Expand Down Expand Up @@ -346,7 +344,6 @@ class ProjectRunner extends RunnerBase {
scenario: testCase.scenario,
projectRoot: testCase.projectRoot,
inputFiles: testCase.inputFiles,
out: testCase.out,
outDir: testCase.outDir,
sourceMap: testCase.sourceMap,
mapRoot: testCase.mapRoot,
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/isolatedModulesOut.errors.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
error TS5053: Option 'out' cannot be specified with option 'isolatedModules'.
error TS5055: Option 'out' cannot be utilized alongside --module or with ES6 modules.
tests/cases/compiler/file2.ts(1,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided.


!!! error TS5053: Option 'out' cannot be specified with option 'isolatedModules'.
!!! error TS5055: Option 'out' cannot be utilized alongside --module or with ES6 modules.
==== tests/cases/compiler/file1.ts (0 errors) ====

export var x;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading