Skip to content

Commit 72ba23c

Browse files
author
Yui T
committed
Address PR: change order of grammar check
1 parent a02edb1 commit 72ba23c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/compiler/checker.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24641,24 +24641,24 @@ namespace ts {
2464124641
}
2464224642

2464324643
function checkGrammarImportCallExpression(node: ImportCall): boolean {
24644-
const arguments = node.arguments;
24645-
if (arguments.length !== 1) {
24646-
return grammarErrorOnNode(node, Diagnostics.Dynamic_import_must_have_one_specifier_as_an_argument);
24644+
if (modulekind === ModuleKind.ES2015) {
24645+
return grammarErrorOnNode(node, Diagnostics.Dynamic_import_cannot_be_used_when_targeting_ECMAScript_2015_modules);
2464724646
}
2464824647

2464924648
if (node.typeArguments) {
2465024649
return grammarErrorOnNode(node, Diagnostics.Dynamic_import_cannot_have_type_arguments);
2465124650
}
2465224651

24652+
const arguments = node.arguments;
24653+
if (arguments.length !== 1) {
24654+
return grammarErrorOnNode(node, Diagnostics.Dynamic_import_must_have_one_specifier_as_an_argument);
24655+
}
24656+
2465324657
// see: parseArgumentOrArrayLiteralElement...we use this function which parse arguments of callExpression to parse specifier for dynamic import.
2465424658
// parseArgumentOrArrayLiteralElement allows spread element to be in an argument list which is not allowed as specifier in dynamic import.
2465524659
if (isSpreadExpression(arguments[0])) {
2465624660
return grammarErrorOnNode(arguments[0], Diagnostics.Specifier_of_dynamic_import_cannot_be_spread_element);
2465724661
}
24658-
24659-
if (modulekind === ModuleKind.ES2015) {
24660-
grammarErrorOnNode(node, Diagnostics.Dynamic_import_cannot_be_used_when_targeting_ECMAScript_2015_modules);
24661-
}
2466224662
}
2466324663
}
2466424664

0 commit comments

Comments
 (0)