Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6e0d7bf

Browse files
committed
test: add test on import { "foo" }
1 parent 90b420a commit 6e0d7bf

4 files changed

Lines changed: 10 additions & 2 deletions

File tree

packages/babel-parser/src/parser/error-message.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const ErrorMessages = Object.freeze({
5656
"Illegal 'use strict' directive in function with non-simple parameter list",
5757
IllegalReturn: "'return' outside of function",
5858
ImportBindingIsString:
59-
"Can not use string literal as an imported binding.\n- Did you mean `import { %0 as foo }`?",
59+
'Can not use string literal as an imported binding.\n- Did you mean `import { "%0" as foo }`?',
6060
ImportCallArgumentTrailingComma:
6161
"Trailing comma is disallowed inside import(...) arguments",
6262
ImportCallArity: "import() requires exactly %0",

packages/babel-parser/src/parser/statement.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2261,7 +2261,7 @@ export default class StatementParser extends ExpressionParser {
22612261
throw this.raise(
22622262
specifier.start,
22632263
Errors.ImportBindingIsString,
2264-
imported.extra.raw,
2264+
imported.value,
22652265
);
22662266
}
22672267
this.checkReservedWord(imported.name, specifier.start, true, true);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import { "foo" } from "foo";
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"sourceType": "module",
3+
"plugins": [
4+
"moduleStringNames"
5+
],
6+
"throws": "Can not use string literal as an imported binding.\n- Did you mean `import { \"foo\" as foo }`? (1:9)"
7+
}

0 commit comments

Comments
 (0)