mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-26 00:36:29 -05:00
Allow JS with isolated modules (#31483)
* Allow JS with isolated modules Previously legacy JS code was not allowed; it was required to use ES6 module syntax. Unfortunately, the check happens after parsing but before binding, and the commonjs module indicator isn't set until binding because it's not syntactically simple like the ES6 module indicator, which is set during parsing. So I decided that JS should be allowed during isolatedModules unconditionally. We're not going to be transforming it anyway. * Update baselines * Switch test to outDir instead of noEmit
This commit is contained in:
committed by
GitHub
parent
ae7a1b4f56
commit
4d27361680
@@ -655,7 +655,7 @@
|
||||
"category": "Error",
|
||||
"code": 1207
|
||||
},
|
||||
"Cannot compile namespaces when the '--isolatedModules' flag is provided.": {
|
||||
"All files must be modules when the '--isolatedModules' flag is provided.": {
|
||||
"category": "Error",
|
||||
"code": 1208
|
||||
},
|
||||
|
||||
@@ -2858,10 +2858,10 @@ namespace ts {
|
||||
createDiagnosticForOptionName(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target");
|
||||
}
|
||||
|
||||
const firstNonExternalModuleSourceFile = find(files, f => !isExternalModule(f) && !f.isDeclarationFile && f.scriptKind !== ScriptKind.JSON);
|
||||
const firstNonExternalModuleSourceFile = find(files, f => !isExternalModule(f) && !isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== ScriptKind.JSON);
|
||||
if (firstNonExternalModuleSourceFile) {
|
||||
const span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
|
||||
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
|
||||
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.All_files_must_be_modules_when_the_isolatedModules_flag_is_provided));
|
||||
}
|
||||
}
|
||||
else if (firstNonAmbientExternalModuleSourceFile && languageVersion < ScriptTarget.ES2015 && options.module === ModuleKind.None) {
|
||||
|
||||
Reference in New Issue
Block a user