Skip to content

Commit

Permalink
test: add test on import { "foo" }
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Oct 9, 2020
1 parent 90b420a commit 6e0d7bf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/babel-parser/src/parser/error-message.js
Expand Up @@ -56,7 +56,7 @@ export const ErrorMessages = Object.freeze({
"Illegal 'use strict' directive in function with non-simple parameter list",
IllegalReturn: "'return' outside of function",
ImportBindingIsString:
"Can not use string literal as an imported binding.\n- Did you mean `import { %0 as foo }`?",
'Can not use string literal as an imported binding.\n- Did you mean `import { "%0" as foo }`?',
ImportCallArgumentTrailingComma:
"Trailing comma is disallowed inside import(...) arguments",
ImportCallArity: "import() requires exactly %0",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-parser/src/parser/statement.js
Expand Up @@ -2261,7 +2261,7 @@ export default class StatementParser extends ExpressionParser {
throw this.raise(
specifier.start,
Errors.ImportBindingIsString,
imported.extra.raw,
imported.value,
);
}
this.checkReservedWord(imported.name, specifier.start, true, true);
Expand Down
@@ -0,0 +1 @@
import { "foo" } from "foo";
@@ -0,0 +1,7 @@
{
"sourceType": "module",
"plugins": [
"moduleStringNames"
],
"throws": "Can not use string literal as an imported binding.\n- Did you mean `import { \"foo\" as foo }`? (1:9)"
}

0 comments on commit 6e0d7bf

Please sign in to comment.