fix: disallow import assertionts in export without from (#12264)
This commit is contained in:
parent
a8c66f4680
commit
b7754d3c82
@ -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();
|
||||
@ -1914,11 +1918,6 @@ export default class StatementParser extends ExpressionParser {
|
||||
}
|
||||
}
|
||||
|
||||
const assertions = this.maybeParseImportAssertions();
|
||||
if (assertions) {
|
||||
node.assertions = assertions;
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
|
||||
@ -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)"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user