Allow dynamic import attributes in --module preserve (#59005)

This commit is contained in:
Andrew Branch
2024-06-25 07:31:32 -07:00
committed by GitHub
parent 6c01f6c584
commit fa4f2e5148
6 changed files with 45 additions and 33 deletions

View File

@@ -51914,13 +51914,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
const nodeArguments = node.arguments;
if (moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.NodeNext && moduleKind !== ModuleKind.Node16) {
if (moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.NodeNext && moduleKind !== ModuleKind.Node16 && moduleKind !== ModuleKind.Preserve) {
// We are allowed trailing comma after proposal-import-assertions.
checkGrammarForDisallowedTrailingComma(nodeArguments);
if (nodeArguments.length > 1) {
const importAttributesArgument = nodeArguments[1];
return grammarErrorOnNode(importAttributesArgument, Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext);
return grammarErrorOnNode(importAttributesArgument, Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_nodenext_or_preserve);
}
}

View File

@@ -1028,7 +1028,7 @@
"category": "Error",
"code": 1323
},
"Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'.": {
"Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', 'nodenext', or 'preserve'.": {
"category": "Error",
"code": 1324
},