fix trailing comma should not allowed in dynamic import argument
This commit is contained in:
parent
2f6c65e691
commit
d7601b755f
|
@ -31178,7 +31178,7 @@ namespace ts {
|
|||
if (nodeArguments.length !== 1) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Dynamic_import_must_have_one_specifier_as_an_argument);
|
||||
}
|
||||
|
||||
checkGrammarForDisallowedTrailingComma(nodeArguments);
|
||||
// see: parseArgumentOrArrayLiteralElement...we use this function which parse arguments of callExpression to parse specifier for dynamic import.
|
||||
// parseArgumentOrArrayLiteralElement allows spread element to be in an argument list which is not allowed as specifier in dynamic import.
|
||||
if (isSpreadElement(nodeArguments[0])) {
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
tests/cases/compiler/dynamicImportTrailingComma.ts(2,12): error TS1009: Trailing comma not allowed.
|
||||
|
||||
|
||||
==== tests/cases/compiler/dynamicImportTrailingComma.ts (1 errors) ====
|
||||
const path = './foo';
|
||||
import(path,);
|
||||
~
|
||||
!!! error TS1009: Trailing comma not allowed.
|
7
tests/baselines/reference/dynamicImportTrailingComma.js
Normal file
7
tests/baselines/reference/dynamicImportTrailingComma.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
//// [dynamicImportTrailingComma.ts]
|
||||
const path = './foo';
|
||||
import(path,);
|
||||
|
||||
//// [dynamicImportTrailingComma.js]
|
||||
var path = './foo';
|
||||
Promise.resolve().then(function () { return require(path); });
|
|
@ -0,0 +1,7 @@
|
|||
=== tests/cases/compiler/dynamicImportTrailingComma.ts ===
|
||||
const path = './foo';
|
||||
>path : Symbol(path, Decl(dynamicImportTrailingComma.ts, 0, 5))
|
||||
|
||||
import(path,);
|
||||
>path : Symbol(path, Decl(dynamicImportTrailingComma.ts, 0, 5))
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
=== tests/cases/compiler/dynamicImportTrailingComma.ts ===
|
||||
const path = './foo';
|
||||
>path : "./foo"
|
||||
>'./foo' : "./foo"
|
||||
|
||||
import(path,);
|
||||
>import(path,) : Promise<any>
|
||||
>path : "./foo"
|
||||
|
4
tests/cases/compiler/dynamicImportTrailingComma.ts
Normal file
4
tests/cases/compiler/dynamicImportTrailingComma.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
// @skipLibCheck: true
|
||||
// @lib: es6
|
||||
const path = './foo';
|
||||
import(path,);
|
Loading…
Reference in a new issue