Skip to content

Commit bb28424

Browse files
committed
Removed errors for missing module specifier
(cherry picked from commit f2e7f9f)
1 parent ef90492 commit bb28424

4 files changed

Lines changed: 2 additions & 19 deletions

File tree

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,8 @@ namespace ts {
601601
const options: CompilerOptions = {};
602602
const errors: Diagnostic[] = [];
603603

604+
options.module = ModuleKind.CommonJS;
604605
if (configFileName && getBaseFileName(configFileName) === "jsconfig.json") {
605-
options.module = ModuleKind.CommonJS;
606606
options.allowJs = true;
607607
}
608608

src/compiler/diagnosticMessages.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,6 @@
447447
"category": "Error",
448448
"code": 1147
449449
},
450-
"Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.": {
451-
"category": "Error",
452-
"code": 1148
453-
},
454450
"File name '{0}' differs from already included file name '{1}' only in casing": {
455451
"category": "Error",
456452
"code": 1149
@@ -2135,10 +2131,6 @@
21352131
"category": "Error",
21362132
"code": 5042
21372133
},
2138-
"Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher.": {
2139-
"category": "Error",
2140-
"code": 5047
2141-
},
21422134
"Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": {
21432135
"category": "Error",
21442136
"code": 5051

src/compiler/program.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,21 +1652,12 @@ namespace ts {
16521652

16531653
const firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
16541654
if (options.isolatedModules) {
1655-
if (!options.module && languageVersion < ScriptTarget.ES6) {
1656-
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher));
1657-
}
1658-
16591655
const firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
16601656
if (firstNonExternalModuleSourceFile) {
16611657
const span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
16621658
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
16631659
}
16641660
}
1665-
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) {
1666-
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
1667-
const span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
1668-
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file));
1669-
}
16701661

16711662
// Cannot specify module gen target of es6 when below es6
16721663
if (options.module === ModuleKind.ES6 && languageVersion < ScriptTarget.ES6) {

src/compiler/tsc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ namespace ts {
376376
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
377377
return;
378378
}
379-
const configParseResult = parseJsonConfigFileContent(configObject, sys, getNormalizedAbsolutePath(getDirectoryPath(configFileName), sys.getCurrentDirectory()), commandLine.options);
379+
const configParseResult = parseJsonConfigFileContent(configObject, sys, getNormalizedAbsolutePath(getDirectoryPath(configFileName), sys.getCurrentDirectory()), commandLine.options, configFileName);
380380
if (configParseResult.errors.length > 0) {
381381
reportDiagnostics(configParseResult.errors, /* compilerHost */ undefined);
382382
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);

0 commit comments

Comments
 (0)