Skip to content

TS5.5-beta injects a random @ts-expect-error comment in the generated .d.ts filesΒ #58698

@nicolo-ribaudo

Description

@nicolo-ribaudo

πŸ”Ž Search Terms

comment 5.5 invalid injected inlined

πŸ•— Version & Regression Information

  • This changed in version 5.5-beta

⏯ Playground Link

No response

πŸ’» Code

  1. Clone https://github.com/nicolo-ribaudo/babel/tree/ts-5.5-random-comment
  2. Run yarn to install all deps
  3. Run make generate-tsconfig to generate all the tsconfig.json files
  4. Run yarn tsc -b ./packages/babel-helper-plugin-utils/tsconfig.json

If you ever need to reset the TS state (e.g. delete all .tsbuildinfo and .d.ts files), run make clean-dts.

πŸ™ Actual behavior

dts/packages/babel-parser/src/plugins/typescript/index.d.ts, line 540 contains a random @ts-expect-error comment:

        parseExprListItem(this: Parser, allowEmpty?: boolean, refExpressionErrors?: ExpressionErrors | null, allowPlaceholder?: boolean | // @ts-expect-error todo(flow->ts) 0121
        null): N.Expression | null;

That parseExprListItem is inlined there from another file, that doesn't have that comment:
https://github.com/nicolo-ribaudo/babel/blob/e5726bde94899149d60706698a0f0a968208bf60/packages/babel-parser/src/parser/expression.ts#L2711-L2728

Instead, that comment is coming from
https://github.com/nicolo-ribaudo/babel/blob/e5726bde94899149d60706698a0f0a968208bf60/packages/babel-parser/src/plugins/typescript/index.ts#L2637-L2642

πŸ™‚ Expected behavior

The comment shouldn't be there

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions