@@ -1048,7 +1048,7 @@ namespace ts {
10481048 const builtinGlobals = createSymbolTable();
10491049 builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
10501050
1051- // Extensions suggested for path imports when module resolution is node12 or higher.
1051+ // Extensions suggested for path imports when module resolution is node16 or higher.
10521052 // The first element of each tuple is the extension a file has.
10531053 // The second element of each tuple is the extension that should be used in a path import.
10541054 // e.g. if we want to import file `foo.mts`, we should write `import {} from "./foo.mjs".
@@ -3528,7 +3528,7 @@ namespace ts {
35283528 if (resolvedModule.isExternalLibraryImport && !resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
35293529 errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference);
35303530 }
3531- if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node12 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) {
3531+ if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) {
35323532 const isSyncImport = (currentSourceFile.impliedNodeFormat === ModuleKind.CommonJS && !findAncestor(location, isImportCall)) || !!findAncestor(location, isImportEqualsDeclaration);
35333533 const overrideClauseHost = findAncestor(location, l => isImportTypeNode(l) || isExportDeclaration(l) || isImportDeclaration(l)) as ImportTypeNode | ImportDeclaration | ExportDeclaration | undefined;
35343534 const overrideClause = overrideClauseHost && isImportTypeNode(overrideClauseHost) ? overrideClauseHost.assertions?.assertClause : overrideClauseHost?.assertClause;
@@ -3596,7 +3596,7 @@ namespace ts {
35963596 const tsExtension = tryExtractTSExtension(moduleReference);
35973597 const isExtensionlessRelativePathImport = pathIsRelative(moduleReference) && !hasExtension(moduleReference);
35983598 const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
3599- const resolutionIsNode12OrNext = moduleResolutionKind === ModuleResolutionKind.Node12 ||
3599+ const resolutionIsNode16OrNext = moduleResolutionKind === ModuleResolutionKind.Node16 ||
36003600 moduleResolutionKind === ModuleResolutionKind.NodeNext;
36013601 if (tsExtension) {
36023602 const diag = Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead;
@@ -3617,16 +3617,16 @@ namespace ts {
36173617 hasJsonModuleEmitEnabled(compilerOptions)) {
36183618 error(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
36193619 }
3620- else if (mode === ModuleKind.ESNext && resolutionIsNode12OrNext && isExtensionlessRelativePathImport) {
3620+ else if (mode === ModuleKind.ESNext && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) {
36213621 const absoluteRef = getNormalizedAbsolutePath(moduleReference, getDirectoryPath(currentSourceFile.path));
36223622 const suggestedExt = suggestedExtensions.find(([actualExt, _importExt]) => host.fileExists(absoluteRef + actualExt))?.[1];
36233623 if (suggestedExt) {
36243624 error(errorNode,
3625- Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0 ,
3625+ Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0 ,
36263626 moduleReference + suggestedExt);
36273627 }
36283628 else {
3629- error(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path );
3629+ error(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path );
36303630 }
36313631 }
36323632 else {
@@ -6191,7 +6191,7 @@ namespace ts {
61916191 const targetFile = getSourceFileOfModule(chain[0]);
61926192 let specifier: string | undefined;
61936193 let assertion: ImportTypeAssertionContainer | undefined;
6194- if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node12 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) {
6194+ if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) {
61956195 // An `import` type directed at an esm format file is only going to resolve in esm mode - set the esm mode assertion
61966196 if (targetFile?.impliedNodeFormat === ModuleKind.ESNext && targetFile.impliedNodeFormat !== contextFile?.impliedNodeFormat) {
61976197 specifier = getSpecifierForModuleSymbol(chain[0], context, ModuleKind.ESNext);
@@ -6208,7 +6208,7 @@ namespace ts {
62086208 }
62096209 if (!(context.flags & NodeBuilderFlags.AllowNodeModulesRelativePaths) && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) {
62106210 const oldSpecifier = specifier;
6211- if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node12 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) {
6211+ if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) {
62126212 // We might be able to write a portable import type using a mode override; try specifier generation again, but with a different mode set
62136213 const swappedMode = contextFile?.impliedNodeFormat === ModuleKind.ESNext ? ModuleKind.CommonJS : ModuleKind.ESNext;
62146214 specifier = getSpecifierForModuleSymbol(chain[0], context, swappedMode);
@@ -32060,13 +32060,13 @@ namespace ts {
3206032060 }
3206132061
3206232062 function checkImportMetaProperty(node: MetaProperty) {
32063- if (moduleKind === ModuleKind.Node12 || moduleKind === ModuleKind.NodeNext) {
32063+ if (moduleKind === ModuleKind.Node16 || moduleKind === ModuleKind.NodeNext) {
3206432064 if (getSourceFileOfNode(node).impliedNodeFormat !== ModuleKind.ESNext) {
3206532065 error(node, Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output);
3206632066 }
3206732067 }
3206832068 else if (moduleKind < ModuleKind.ES2020 && moduleKind !== ModuleKind.System) {
32069- error(node, Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext );
32069+ error(node, Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext );
3207032070 }
3207132071 const file = getSourceFileOfNode(node);
3207232072 Debug.assert(!!(file.flags & NodeFlags.PossiblyContainsImportMeta), "Containing file is missing import meta node flag.");
@@ -33101,10 +33101,11 @@ namespace ts {
3310133101 Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module);
3310233102 diagnostics.add(diagnostic);
3310333103 }
33104- if ((moduleKind !== ModuleKind.ES2022 && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System && !(moduleKind === ModuleKind.NodeNext && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.ESNext)) || languageVersion < ScriptTarget.ES2017) {
33104+ if ((moduleKind !== ModuleKind.ES2022 && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System && !(moduleKind >= ModuleKind.Node16 && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.ESNext)) || languageVersion < ScriptTarget.ES2017) {
3310533105 span = getSpanOfTokenAtPosition(sourceFile, node.pos);
3310633106 const diagnostic = createFileDiagnostic(sourceFile, span.start, span.length,
33107- Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher);
33107+ // TODO
33108+ Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher);
3310833109 diagnostics.add(diagnostic);
3310933110 }
3311033111 }
@@ -35809,8 +35810,8 @@ namespace ts {
3580935810 if (node.assertions) {
3581035811 const override = getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode);
3581135812 if (override) {
35812- if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node12 && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) {
35813- grammarErrorOnNode(node.assertions.assertClause, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext );
35813+ if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) {
35814+ grammarErrorOnNode(node.assertions.assertClause, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext );
3581435815 }
3581535816 }
3581635817 }
@@ -37428,7 +37429,7 @@ namespace ts {
3742837429
3742937430 function checkCollisionWithRequireExportsInGeneratedCode(node: Node, name: Identifier | undefined) {
3743037431 // No need to check for require or exports for ES6 modules and later
37431- if (moduleKind >= ModuleKind.ES2015 && !(moduleKind >= ModuleKind.Node12 && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS)) {
37432+ if (moduleKind >= ModuleKind.ES2015 && !(moduleKind >= ModuleKind.Node16 && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS)) {
3743237433 return;
3743337434 }
3743437435
@@ -40703,8 +40704,8 @@ namespace ts {
4070340704 const validForTypeAssertions = isExclusivelyTypeOnlyImportOrExport(declaration);
4070440705 const override = getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
4070540706 if (validForTypeAssertions && override) {
40706- if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node12 && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) {
40707- return grammarErrorOnNode(declaration.assertClause, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext );
40707+ if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) {
40708+ return grammarErrorOnNode(declaration.assertClause, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext );
4070840709 }
4070940710 return; // Other grammar checks do not apply to type-only imports with resolution mode assertions
4071040711 }
@@ -44173,9 +44174,9 @@ namespace ts {
4417344174 diagnostics.add(createDiagnosticForNode(forInOrOfStatement.awaitModifier,
4417444175 Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module));
4417544176 }
44176- if ((moduleKind !== ModuleKind.ES2022 && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System && !(moduleKind === ModuleKind.NodeNext && getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ModuleKind.ESNext)) || languageVersion < ScriptTarget.ES2017) {
44177+ if ((moduleKind !== ModuleKind.ES2022 && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System && !(moduleKind >= ModuleKind.Node16 && getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ModuleKind.ESNext)) || languageVersion < ScriptTarget.ES2017) {
4417744178 diagnostics.add(createDiagnosticForNode(forInOrOfStatement.awaitModifier,
44178- Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher ));
44179+ Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher ));
4417944180 }
4418044181 }
4418144182 }
@@ -44947,7 +44948,7 @@ namespace ts {
4494744948
4494844949 function checkGrammarImportCallExpression(node: ImportCall): boolean {
4494944950 if (moduleKind === ModuleKind.ES2015) {
44950- return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext );
44951+ return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext );
4495144952 }
4495244953
4495344954 if (node.typeArguments) {
@@ -44961,7 +44962,7 @@ namespace ts {
4496144962
4496244963 if (nodeArguments.length > 1) {
4496344964 const assertionArgument = nodeArguments[1];
44964- return grammarErrorOnNode(assertionArgument, Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext );
44965+ return grammarErrorOnNode(assertionArgument, Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext );
4496544966 }
4496644967 }
4496744968
0 commit comments