Skip to content

Commit fca24c2

Browse files
committed
Add module: es2020
1 parent f1c0300 commit fca24c2

File tree

66 files changed

+119
-84
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+119
-84
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31247,7 +31247,7 @@ namespace ts {
3124731247
*/
3124831248
function checkClassNameCollisionWithObject(name: Identifier): void {
3124931249
if (languageVersion === ScriptTarget.ES5 && name.escapedText === "Object"
31250-
&& moduleKind !== ModuleKind.ES2015 && moduleKind !== ModuleKind.ESNext) {
31250+
&& moduleKind < ModuleKind.ES2015) {
3125131251
error(name, Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494
3125231252
}
3125331253
}
@@ -32422,7 +32422,7 @@ namespace ts {
3242232422
error(node.moduleSpecifier, Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
3242332423
}
3242432424

32425-
if (moduleKind !== ModuleKind.System && moduleKind !== ModuleKind.ES2015 && moduleKind !== ModuleKind.ESNext) {
32425+
if (moduleKind !== ModuleKind.System && moduleKind < ModuleKind.ES2015) {
3242632426
checkExternalEmitHelpers(node, ExternalEmitHelpers.ExportStar);
3242732427
}
3242832428
}
@@ -35630,7 +35630,9 @@ namespace ts {
3563035630
return grammarErrorOnNode(node.exclamationToken, Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation);
3563135631
}
3563235632

35633-
if (compilerOptions.module !== ModuleKind.ES2015 && compilerOptions.module !== ModuleKind.ESNext && compilerOptions.module !== ModuleKind.System && !compilerOptions.noEmit &&
35633+
const moduleKind = getEmitModuleKind(compilerOptions);
35634+
35635+
if (moduleKind < ModuleKind.ES2015 && moduleKind !== ModuleKind.System && !compilerOptions.noEmit &&
3563435636
!(node.parent.parent.flags & NodeFlags.Ambient) && hasModifier(node.parent.parent, ModifierFlags.Export)) {
3563535637
checkESModuleMarker(node.name);
3563635638
}
@@ -35976,7 +35978,7 @@ namespace ts {
3597635978

3597735979
function checkGrammarImportCallExpression(node: ImportCall): boolean {
3597835980
if (moduleKind === ModuleKind.ES2015) {
35979-
return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd);
35981+
return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_or_umd);
3598035982
}
3598135983

3598235984
if (node.typeArguments) {

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ namespace ts {
252252
umd: ModuleKind.UMD,
253253
es6: ModuleKind.ES2015,
254254
es2015: ModuleKind.ES2015,
255+
es2020: ModuleKind.ES2020,
255256
esnext: ModuleKind.ESNext
256257
}),
257258
affectsModuleResolution: true,

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@
903903
"category": "Error",
904904
"code": 1322
905905
},
906-
"Dynamic imports are only supported when the '--module' flag is set to 'esnext', 'commonjs', 'amd', 'system', or 'umd'.": {
906+
"Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.": {
907907
"category": "Error",
908908
"code": 1323
909909
},

src/compiler/factory.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5156,8 +5156,7 @@ namespace ts {
51565156
const moduleKind = getEmitModuleKind(compilerOptions);
51575157
let create = (hasExportStarsToExportValues || (compilerOptions.esModuleInterop && hasImportStarOrImportDefault))
51585158
&& moduleKind !== ModuleKind.System
5159-
&& moduleKind !== ModuleKind.ES2015
5160-
&& moduleKind !== ModuleKind.ESNext;
5159+
&& moduleKind < ModuleKind.ES2015;
51615160
if (!create) {
51625161
const helpers = getEmitHelpers(node);
51635162
if (helpers) {

src/compiler/transformer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace ts {
33
function getModuleTransformer(moduleKind: ModuleKind): TransformerFactory<SourceFile | Bundle> {
44
switch (moduleKind) {
55
case ModuleKind.ESNext:
6+
case ModuleKind.ES2020:
67
case ModuleKind.ES2015:
78
return transformES2015Module;
89
case ModuleKind.System:

src/compiler/transformers/ts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2464,6 +2464,7 @@ namespace ts {
24642464
return isExportOfNamespace(node)
24652465
|| (isExternalModuleExport(node)
24662466
&& moduleKind !== ModuleKind.ES2015
2467+
&& moduleKind !== ModuleKind.ES2020
24672468
&& moduleKind !== ModuleKind.ESNext
24682469
&& moduleKind !== ModuleKind.System);
24692470
}

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5026,6 +5026,7 @@ namespace ts {
50265026
// Non-ES module kinds should not come between ES2015 (the earliest ES module kind) and ESNext (the last ES
50275027
// module kind).
50285028
ES2015 = 5,
5029+
ES2020 = 6,
50295030
ESNext = 99
50305031
}
50315032

src/compiler/utilities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7542,6 +7542,7 @@ namespace ts {
75427542
case ModuleKind.CommonJS:
75437543
case ModuleKind.AMD:
75447544
case ModuleKind.ES2015:
7545+
case ModuleKind.ES2020:
75457546
case ModuleKind.ESNext:
75467547
return true;
75477548
default:

src/services/codefixes/importFixes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ namespace ts.codefix {
378378
return ImportKind.Equals;
379379
case ModuleKind.System:
380380
case ModuleKind.ES2015:
381+
case ModuleKind.ES2020:
381382
case ModuleKind.ESNext:
382383
case ModuleKind.None:
383384
// Fall back to the `import * as ns` style import.

src/testRunner/unittests/config/commandLineParsing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ namespace ts {
109109
start: undefined,
110110
length: undefined,
111111
}, {
112-
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'esnext'.",
112+
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'.",
113113
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
114114
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
115115

0 commit comments

Comments
 (0)