Skip to content

Commit

Permalink
add missing ExportNamespaceSpecifier in spec.md (#13691)
Browse files Browse the repository at this point in the history
* add missing ExportNamespaceSpecifier in spec.md

* add constrain note in ExportNamedDeclaration

Co-authored-by: 刘地军 <dijun.ldj@antgroup.com>
  • Loading branch information
flyinox and 刘地军 committed Aug 20, 2021
1 parent 8ae4159 commit 1d4bd31
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/babel-parser/ast/spec.md
Expand Up @@ -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)

Expand Down Expand Up @@ -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 ];
}
Expand All @@ -1351,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

Expand All @@ -1364,6 +1366,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
Expand Down

0 comments on commit 1d4bd31

Please sign in to comment.