mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add module: es2020 (#33893)
This commit is contained in:
committed by
Daniel Rosenwasser
parent
4c7844be74
commit
deb5288e31
@@ -31598,7 +31598,7 @@ namespace ts {
|
||||
*/
|
||||
function checkClassNameCollisionWithObject(name: Identifier): void {
|
||||
if (languageVersion === ScriptTarget.ES5 && name.escapedText === "Object"
|
||||
&& moduleKind !== ModuleKind.ES2015 && moduleKind !== ModuleKind.ESNext) {
|
||||
&& moduleKind < ModuleKind.ES2015) {
|
||||
error(name, Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494
|
||||
}
|
||||
}
|
||||
@@ -32763,7 +32763,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 && moduleKind !== ModuleKind.ESNext) {
|
||||
if (moduleKind !== ModuleKind.System && moduleKind < ModuleKind.ES2015) {
|
||||
checkExternalEmitHelpers(node, ExternalEmitHelpers.ExportStar);
|
||||
}
|
||||
}
|
||||
@@ -35977,7 +35977,9 @@ namespace ts {
|
||||
return grammarErrorOnNode(node.exclamationToken, Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation);
|
||||
}
|
||||
|
||||
if (compilerOptions.module !== ModuleKind.ES2015 && compilerOptions.module !== ModuleKind.ESNext && compilerOptions.module !== ModuleKind.System && !compilerOptions.noEmit &&
|
||||
const moduleKind = getEmitModuleKind(compilerOptions);
|
||||
|
||||
if (moduleKind < ModuleKind.ES2015 && moduleKind !== ModuleKind.System && !compilerOptions.noEmit &&
|
||||
!(node.parent.parent.flags & NodeFlags.Ambient) && hasModifier(node.parent.parent, ModifierFlags.Export)) {
|
||||
checkESModuleMarker(node.name);
|
||||
}
|
||||
@@ -36323,7 +36325,7 @@ namespace ts {
|
||||
|
||||
function checkGrammarImportCallExpression(node: ImportCall): boolean {
|
||||
if (moduleKind === ModuleKind.ES2015) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd);
|
||||
return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_or_umd);
|
||||
}
|
||||
|
||||
if (node.typeArguments) {
|
||||
|
||||
@@ -304,6 +304,7 @@ namespace ts {
|
||||
umd: ModuleKind.UMD,
|
||||
es6: ModuleKind.ES2015,
|
||||
es2015: ModuleKind.ES2015,
|
||||
es2020: ModuleKind.ES2020,
|
||||
esnext: ModuleKind.ESNext
|
||||
}),
|
||||
affectsModuleResolution: true,
|
||||
|
||||
@@ -911,7 +911,7 @@
|
||||
"category": "Error",
|
||||
"code": 1322
|
||||
},
|
||||
"Dynamic imports are only supported when the '--module' flag is set to 'esnext', 'commonjs', 'amd', 'system', or 'umd'.": {
|
||||
"Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.": {
|
||||
"category": "Error",
|
||||
"code": 1323
|
||||
},
|
||||
|
||||
@@ -1509,8 +1509,7 @@ namespace ts {
|
||||
const moduleKind = getEmitModuleKind(compilerOptions);
|
||||
let create = (hasExportStarsToExportValues || (compilerOptions.esModuleInterop && hasImportStarOrImportDefault))
|
||||
&& moduleKind !== ModuleKind.System
|
||||
&& moduleKind !== ModuleKind.ES2015
|
||||
&& moduleKind !== ModuleKind.ESNext;
|
||||
&& moduleKind < ModuleKind.ES2015;
|
||||
if (!create) {
|
||||
const helpers = getEmitHelpers(node);
|
||||
if (helpers) {
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace ts {
|
||||
function getModuleTransformer(moduleKind: ModuleKind): TransformerFactory<SourceFile | Bundle> {
|
||||
switch (moduleKind) {
|
||||
case ModuleKind.ESNext:
|
||||
case ModuleKind.ES2020:
|
||||
case ModuleKind.ES2015:
|
||||
return transformECMAScriptModule;
|
||||
case ModuleKind.System:
|
||||
|
||||
@@ -2473,6 +2473,7 @@ namespace ts {
|
||||
return isExportOfNamespace(node)
|
||||
|| (isExternalModuleExport(node)
|
||||
&& moduleKind !== ModuleKind.ES2015
|
||||
&& moduleKind !== ModuleKind.ES2020
|
||||
&& moduleKind !== ModuleKind.ESNext
|
||||
&& moduleKind !== ModuleKind.System);
|
||||
}
|
||||
|
||||
@@ -5125,6 +5125,7 @@ namespace ts {
|
||||
// Non-ES module kinds should not come between ES2015 (the earliest ES module kind) and ESNext (the last ES
|
||||
// module kind).
|
||||
ES2015 = 5,
|
||||
ES2020 = 6,
|
||||
ESNext = 99
|
||||
}
|
||||
|
||||
|
||||
@@ -5184,6 +5184,7 @@ namespace ts {
|
||||
case ModuleKind.CommonJS:
|
||||
case ModuleKind.AMD:
|
||||
case ModuleKind.ES2015:
|
||||
case ModuleKind.ES2020:
|
||||
case ModuleKind.ESNext:
|
||||
return true;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user