Skip to content

Commit

Permalink
fix: disallow import assertionts in export without from (#12264)
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Oct 28, 2020
1 parent a8c66f4 commit b7754d3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/babel-parser/src/parser/statement.js
Expand Up @@ -1906,6 +1906,10 @@ export default class StatementParser extends ExpressionParser {
if (this.eatContextual("from")) {
node.source = this.parseImportSource();
this.checkExport(node);
const assertions = this.maybeParseImportAssertions();
if (assertions) {
node.assertions = assertions;
}
} else {
if (expect) {
this.unexpected();
Expand All @@ -1914,11 +1918,6 @@ export default class StatementParser extends ExpressionParser {
}
}
const assertions = this.maybeParseImportAssertions();
if (assertions) {
node.assertions = assertions;
}
this.semicolon();
}
Expand Down
@@ -0,0 +1,2 @@
const foo = 1;
export { foo } assert { type: "json" };
@@ -0,0 +1,9 @@
{
"plugins": [
[
"importAssertions"
]
],
"sourceType": "module",
"throws": "Unexpected token, expected \";\" (2:15)"
}

0 comments on commit b7754d3

Please sign in to comment.