Repository: babel/babel
File: packages/babel-parser/src/plugins/estree.ts (TypeScript)

Code before:

      super.toReferencedArguments(node);
    }

    parseExport(
      unfinished: Undone<N.AnyExport>,
      decorators: N.Decorator[] | null,
    ) {
      const exportStartLoc = this.state.lastTokStartLoc!;
      const node = super.parseExport(unfinished, decorators);

      switch (node.type) {
        case "ExportAllDeclaration":
          // @ts-expect-error mutating AST types
          node.exported = null;
          break;

        case "ExportNamedDeclaration":
          if (
            node.specifiers.length === 1 &&
            node.specifiers[0].type === "ExportNamespaceSpecifier"
          ) {
            this.castNodeTo(node, "ExportAllDeclaration");
            // @ts-expect-error mutating AST types
            node.exported = node.specifiers[0].exported;
            // @ts-expect-error expected
            delete node.specifiers;
          }

        // fallthrough
        case "ExportDefaultDeclaration":
          {
            const { declaration } = node;
            if (
              declaration?.type === "ClassDeclaration" &&
              // @ts-expect-error expected
              declaration.decorators?.length > 0 &&
              // decorator comes before export
              declaration.start === node.start
            ) {
              this.resetStartLocation(
                node,
                // For compatibility with ESLint's keyword-spacing rule, which assumes that an
                // export declaration must start with export.
                // https://github.com/babel/babel/issues/15085
                // Here we reset export declaration's start to be the start of the export token
                exportStartLoc,
              );
            }
          }


Review comment (suggestion):
```suggestion
            // @ts-expect-error The ESTree AST shape differs from the Babel AST
```

In general it'd be great to have something more descriptive than "expected" 😅 

Code after:

      super.toReferencedArguments(node);
    }

    parseExport(
      unfinished: Undone<N.AnyExport>,
      decorators: N.Decorator[] | null,
    ) {
      const exportStartLoc = this.state.lastTokStartLoc!;
      const node = super.parseExport(unfinished, decorators);

      switch (node.type) {
        case "ExportAllDeclaration":
          // @ts-expect-error mutating AST types
          node.exported = null;
          break;

        case "ExportNamedDeclaration":
          if (
            node.specifiers.length === 1 &&
            node.specifiers[0].type === "ExportNamespaceSpecifier"
          ) {
            this.castNodeTo(node, "ExportAllDeclaration");
            // @ts-expect-error mutating AST types
            node.exported = node.specifiers[0].exported;
            // @ts-expect-error The ESTree AST shape differs from the Babel AST
            delete node.specifiers;
          }

        // fallthrough
        case "ExportDefaultDeclaration":
          {
            const { declaration } = node;
            if (
              declaration?.type === "ClassDeclaration" &&
              // @ts-expect-error comparing undefined and number
              declaration.decorators?.length > 0 &&
              // decorator comes before export
              declaration.start === node.start
            ) {
              this.resetStartLocation(
                node,
                // For compatibility with ESLint's keyword-spacing rule, which assumes that an
                // export declaration must start with export.
                // https://github.com/babel/babel/issues/15085
                // Here we reset export declaration's start to be the start of the export token
                exportStartLoc,
              );
            }
          }