mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Care about esnext where we look for es2015 (#18331)
* Care about esnext where we look for es2015 * Update diagnostic message to be more agnostic
This commit is contained in:
@@ -22149,9 +22149,9 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (modulekind === ModuleKind.ES2015 && !isInAmbientContext(node)) {
|
||||
if (modulekind >= ModuleKind.ES2015 && !isInAmbientContext(node)) {
|
||||
// Import equals declaration is deprecated in es6 or above
|
||||
grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
|
||||
grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22187,7 +22187,7 @@ namespace ts {
|
||||
error(node.moduleSpecifier, Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
|
||||
}
|
||||
|
||||
if (modulekind !== ModuleKind.System && modulekind !== ModuleKind.ES2015) {
|
||||
if (modulekind !== ModuleKind.System && modulekind !== ModuleKind.ES2015 && modulekind !== ModuleKind.ESNext) {
|
||||
checkExternalEmitHelpers(node, ExternalEmitHelpers.ExportStar);
|
||||
}
|
||||
}
|
||||
@@ -22249,9 +22249,9 @@ namespace ts {
|
||||
checkExternalModuleExports(container);
|
||||
|
||||
if (node.isExportEquals && !isInAmbientContext(node)) {
|
||||
if (modulekind === ModuleKind.ES2015) {
|
||||
if (modulekind >= ModuleKind.ES2015) {
|
||||
// export assignment is not supported in es6 modules
|
||||
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead);
|
||||
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
|
||||
}
|
||||
else if (modulekind === ModuleKind.System) {
|
||||
// system modules does not support export assignment
|
||||
@@ -24851,7 +24851,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
if (compilerOptions.module !== ModuleKind.ES2015 && compilerOptions.module !== ModuleKind.System && !compilerOptions.noEmit &&
|
||||
if (compilerOptions.module !== ModuleKind.ES2015 && compilerOptions.module !== ModuleKind.ESNext && compilerOptions.module !== ModuleKind.System && !compilerOptions.noEmit &&
|
||||
!isInAmbientContext(node.parent.parent) && hasModifier(node.parent.parent, ModifierFlags.Export)) {
|
||||
checkESModuleMarker(node.name);
|
||||
}
|
||||
|
||||
@@ -627,11 +627,11 @@
|
||||
"category": "Error",
|
||||
"code": 1200
|
||||
},
|
||||
"Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead.": {
|
||||
"Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead.": {
|
||||
"category": "Error",
|
||||
"code": 1202
|
||||
},
|
||||
"Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead.": {
|
||||
"Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.": {
|
||||
"category": "Error",
|
||||
"code": 1203
|
||||
},
|
||||
|
||||
@@ -4158,7 +4158,8 @@ namespace ts {
|
||||
const moduleKind = getEmitModuleKind(compilerOptions);
|
||||
let create = hasExportStarsToExportValues
|
||||
&& moduleKind !== ModuleKind.System
|
||||
&& moduleKind !== ModuleKind.ES2015;
|
||||
&& moduleKind !== ModuleKind.ES2015
|
||||
&& moduleKind !== ModuleKind.ESNext;
|
||||
if (!create) {
|
||||
const helpers = getEmitHelpers(node);
|
||||
if (helpers) {
|
||||
|
||||
@@ -521,7 +521,7 @@ namespace ts {
|
||||
|
||||
function visitSourceFile(node: SourceFile) {
|
||||
const alwaysStrict = (compilerOptions.alwaysStrict === undefined ? compilerOptions.strict : compilerOptions.alwaysStrict) &&
|
||||
!(isExternalModule(node) && moduleKind === ModuleKind.ES2015);
|
||||
!(isExternalModule(node) && moduleKind >= ModuleKind.ES2015);
|
||||
return updateSourceFileNode(
|
||||
node,
|
||||
visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict));
|
||||
@@ -2665,6 +2665,7 @@ namespace ts {
|
||||
return isExportOfNamespace(node)
|
||||
|| (isExternalModuleExport(node)
|
||||
&& moduleKind !== ModuleKind.ES2015
|
||||
&& moduleKind !== ModuleKind.ESNext
|
||||
&& moduleKind !== ModuleKind.System);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user