Skip to content

Commit f2e7f9f

Browse files
committed
Removed errors for missing module specifier
1 parent 0e5a93b commit f2e7f9f

File tree

4 files changed

+3
-20
lines changed

4 files changed

+3
-20
lines changed

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@ namespace ts {
575575
const options: CompilerOptions = {};
576576
const errors: Diagnostic[] = [];
577577

578+
options.module = ModuleKind.CommonJS;
578579
if (configFileName && getBaseFileName(configFileName) === "jsconfig.json") {
579-
options.module = ModuleKind.CommonJS;
580580
options.allowJs = true;
581581
}
582582

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,6 @@
439439
"category": "Error",
440440
"code": 1147
441441
},
442-
"Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.": {
443-
"category": "Error",
444-
"code": 1148
445-
},
446442
"File name '{0}' differs from already included file name '{1}' only in casing": {
447443
"category": "Error",
448444
"code": 1149
@@ -2131,10 +2127,6 @@
21312127
"category": "Error",
21322128
"code": 5042
21332129
},
2134-
"Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher.": {
2135-
"category": "Error",
2136-
"code": 5047
2137-
},
21382130
"Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": {
21392131
"category": "Error",
21402132
"code": 5051
@@ -2171,7 +2163,7 @@
21712163
"category": "Error",
21722164
"code": 5059
21732165
},
2174-
2166+
21752167

21762168
"Concatenate and emit output to single file.": {
21772169
"category": "Message",

src/compiler/program.ts

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

12911291
const firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
12921292
if (options.isolatedModules) {
1293-
if (!options.module && languageVersion < ScriptTarget.ES6) {
1294-
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher));
1295-
}
1296-
12971293
const firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
12981294
if (firstNonExternalModuleSourceFile) {
12991295
const span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
13001296
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
13011297
}
13021298
}
1303-
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) {
1304-
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
1305-
const span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
1306-
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));
1307-
}
13081299

13091300
// Cannot specify module gen target of es6 when below es6
13101301
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, getDirectoryPath(configFileName), commandLine.options);
379+
const configParseResult = parseJsonConfigFileContent(configObject, sys, getDirectoryPath(configFileName), 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)