From 6d3ddfbd96963e6154d7f0268e7f841addb05e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=9C=B0=E5=86=9B?= Date: Thu, 19 Aug 2021 12:03:59 +0800 Subject: [PATCH 1/2] add missing ExportNamespaceSpecifier in spec.md --- packages/babel-parser/ast/spec.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/babel-parser/ast/spec.md b/packages/babel-parser/ast/spec.md index 1c934c1ba129..5b14734e0658 100644 --- a/packages/babel-parser/ast/spec.md +++ b/packages/babel-parser/ast/spec.md @@ -119,6 +119,7 @@ These are the core @babel/parser (babylon) AST node types. - [Exports](#exports) - [ExportNamedDeclaration](#exportnameddeclaration) - [ExportSpecifier](#exportspecifier) + - [ExportNamespaceSpecifier](#exportnamespacespecifier) - [ExportDefaultDeclaration](#exportdefaultdeclaration) - [ExportAllDeclaration](#exportalldeclaration) @@ -1339,7 +1340,7 @@ An attribute specified on the ImportDeclaration. interface ExportNamedDeclaration <: ModuleDeclaration { type: "ExportNamedDeclaration"; declaration: Declaration | null; - specifiers: [ ExportSpecifier ]; + specifiers: [ ExportSpecifier | ExportNamespaceSpecifier ]; source: StringLiteral | null; assertions?: [ ImportAttribute ]; } @@ -1364,6 +1365,17 @@ interface ExportSpecifier <: ModuleSpecifier { An exported variable binding, e.g., `{foo}` in `export {foo}` or `{bar as foo}` in `export {bar as foo}`. The `exported` field refers to the name exported in the module. The `local` field refers to the binding into the local module scope. If it is a basic named export, such as in `export {foo}`, both `exported` and `local` are equivalent `Identifier` nodes; in this case an `Identifier` node representing `foo`. If it is an aliased export, such as in `export {bar as foo}`, the `exported` field is an `Identifier` node representing `foo`, and the `local` field is an `Identifier` node representing `bar`. +### ExportNamespaceSpecifier + +```js +interface ExportNamespaceSpecifier <: ModuleSpecifier { + type: "ExportNamespaceSpecifier"; + exported: Identifier; +} +``` + +A namespace export specifier, e.g., `* as foo` in `export * as foo from "mod.js"`. + ### ExportDefaultDeclaration ```js From 780ba7dd2ac50cac6fd312496df2b2dbbee96b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=9C=B0=E5=86=9B?= Date: Fri, 20 Aug 2021 07:47:53 +0800 Subject: [PATCH 2/2] add constrain note in ExportNamedDeclaration --- packages/babel-parser/ast/spec.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/babel-parser/ast/spec.md b/packages/babel-parser/ast/spec.md index 5b14734e0658..8205526f5ec6 100644 --- a/packages/babel-parser/ast/spec.md +++ b/packages/babel-parser/ast/spec.md @@ -1352,6 +1352,7 @@ Note: - Having `declaration` populated with non-empty `specifiers` or non-null `source` results in an invalid state. - If `source` is `null`, for each `specifier` of `specifiers`, `specifier.local` can not be a `StringLiteral`. +- If `specifiers` contains `ExportNamespaceSpecifier`, it must have only one `ExportNamespaceSpecifier`. ### ExportSpecifier