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

Function parseExportDefaultExpression

packages/babel-parser/src/parser/statement.ts:2506–2569  ·  view source on GitHub ↗
(
    this: Parser,
  )

Source from the content-addressed store, hash-verified

2504 }
2505
2506 parseExportDefaultExpression(
2507 this: Parser,
2508 ): N.ExportDefaultDeclaration["declaration"] {
2509 const expr = this.startNode();
2510
2511 if (this.match(tt._function)) {
2512 this.next();
2513 return this.parseFunction(
2514 expr,
2515 ParseFunctionFlag.Declaration | ParseFunctionFlag.NullableId,
2516 );
2517 } else if (this.isAsyncFunction()) {
2518 this.next(); // eat 'async'
2519 this.next(); // eat 'function'
2520 return this.parseFunction(
2521 expr,
2522 ParseFunctionFlag.Declaration |
2523 ParseFunctionFlag.NullableId |
2524 ParseFunctionFlag.Async,
2525 );
2526 }
2527
2528 if (this.match(tt._class)) {
2529 return this.parseClass(expr, true, true);
2530 }
2531
2532 if (this.isContextual(tt._struct)) {
2533 const next = this.nextTokenInLineStart();
2534 const nextCh = this.codePointAtPos(next);
2535 if (
2536 nextCh === charCodes.leftCurlyBrace ||
2537 this.chStartsBindingIdentifier(nextCh, next)
2538 ) {
2539 this.expectPlugin("structs");
2540 return this.parseStructDeclaration(expr, true);
2541 }
2542 }
2543
2544 if (this.match(tt.at)) {
2545 return this.parseClass(
2546 this.maybeTakeDecorators(
2547 this.parseDecorators(false),
2548 this.startNode<N.ClassDeclaration>(),
2549 ),
2550 true,
2551 true,
2552 );
2553 }
2554
2555 if (
2556 this.match(tt._const) ||
2557 this.match(tt._var) ||
2558 (this.isLet() &&
2559 !this.isReservedWordOnNewLineAfterLet(this.nextTokenStart())) ||
2560 this.isUsing() ||
2561 this.isAwaitUsing()
2562 ) {
2563 throw this.raise(Errors.UnsupportedDefaultExport, this.state.startLoc);

Callers

nothing calls this directly

Calls 5

matchMethod · 0.80
nextMethod · 0.80
parseClassMethod · 0.45
semicolonMethod · 0.45

Tested by

no test coverage detected