MCPcopy Create free account
hub / github.com/babel/babel / parseExportDeclaration

Function parseExportDeclaration

packages/babel-parser/src/parser/statement.ts:2572–2606  ·  view source on GitHub ↗
(
    this: Parser,
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    node: Undone<N.ExportNamedDeclaration>,
  )

Source from the content-addressed store, hash-verified

2570
2571 // https://tc39.es/ecma262/#prod-ExportDeclaration
2572 parseExportDeclaration(
2573 this: Parser,
2574 // eslint-disable-next-line @typescript-eslint/no-unused-vars
2575 node: Undone<N.ExportNamedDeclaration>,
2576 ): N.ExportNamedDeclaration["declaration"] | undefined {
2577 if (this.match(tt._class)) {
2578 const node = this.parseClass(
2579 this.startNode<N.ClassDeclaration>(),
2580 true,
2581 false,
2582 );
2583 return node;
2584 }
2585 if (
2586 this.isContextual(tt._struct) &&
2587 this.nextTokenIsIdentifierOnSameLine()
2588 ) {
2589 this.expectPlugin("structs");
2590 const node = this.parseStructDeclaration(
2591 this.startNode<N.StructDeclaration>(),
2592 false,
2593 );
2594 return node;
2595 }
2596 if (this.isContextual(tt._let)) {
2597 // isLet() has seen a binding after `let`. ASI cannot turn `let` into an
2598 // expression after `export`, so parse a declaration even for
2599 // `export let \n if`, where parseStatementContent would apply ASI.
2600 return this.parseVarStatement(
2601 this.startNode<N.VariableDeclaration>(),
2602 "let",
2603 );
2604 }
2605 return this.parseStatementListItem() as N.ExportNamedDeclaration["declaration"];
2606 }
2607
2608 isExportDefaultSpecifier(): boolean {
2609 const { type } = this.state;

Callers

nothing calls this directly

Calls 3

matchMethod · 0.80
parseVarStatementMethod · 0.80
parseClassMethod · 0.45

Tested by

no test coverage detected