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

Function parseExportDeclaration

packages/babel-parser/src/parser/statement.ts:2568–2602  ·  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

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