Skip to content

Commit 3aee4e3

Browse files
JLHwungfisker
andauthored
Disallows specifiers after export * as ns (#15385)
* disallow specifiers after export * as ns * update test cases * ignore js/exports/jsfmt.spec.js e2e tests * Update scripts/integration-tests/e2e-prettier.sh Co-authored-by: fisker Cheung <[email protected]> --------- Co-authored-by: fisker Cheung <[email protected]>
1 parent 91b24d5 commit 3aee4e3

20 files changed

Lines changed: 92 additions & 103 deletions

File tree

packages/babel-generator/test/fixtures/types/ExportSpecifier16/input.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/babel-generator/test/fixtures/types/ExportSpecifier16/options.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/babel-generator/test/fixtures/types/ExportSpecifier16/output.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/babel-generator/test/fixtures/types/ExportSpecifier2/options.json

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * as foo, { bar } from "foo";
1+
export * as default from "foo";

packages/babel-generator/test/fixtures/types/ExportSpecifier4/options.json

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * as foo, { bar } from "foo";
1+
export * as default from "foo";

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2305,13 +2305,14 @@ export default abstract class StatementParser extends ExpressionParser {
23052305
node,
23062306
);
23072307

2308-
if (
2309-
(hasDefault && parseAfterDefault && !hasStar && !hasSpecifiers) ||
2310-
(hasNamespace && parseAfterNamespace && !hasSpecifiers)
2311-
) {
2308+
if (hasDefault && parseAfterDefault && !hasStar && !hasSpecifiers) {
23122309
throw this.unexpected(null, tt.braceL);
23132310
}
23142311

2312+
if (hasNamespace && parseAfterNamespace) {
2313+
throw this.unexpected(null, tt._from);
2314+
}
2315+
23152316
let hasDeclaration;
23162317
if (isFromRequired || hasSpecifiers) {
23172318
hasDeclaration = false;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"throws": "Unexpected token, expected \"from\" (1:25)"
3+
}

packages/babel-parser/test/fixtures/es2020/export-ns-from/ns-and-named/output.json

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)