Skip to content

fix(flow-comments): support anonymous classes - #18564

Merged
JLHwung merged 1 commit into
mainfrom
jlhwung/fix-flow-comments-anonymous-class
Nov 10, 2026
Merged

JLHwung merged 1 commit into
mainfrom
jlhwung/fix-flow-comments-anonymous-class

Conversation

@JLHwung

@JLHwung JLHwung commented Nov 10, 2026

Copy link
Copy Markdown
Contributor
Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
Need backport? Yes
License MIT

In this PR we fix an issue detected by the ongoing TS strict mode migration: The flow-comment transform tries to attach comments to the path of a class id, even though the class might be an anonymous one. In this PR we attach the comments as inner comments of the class expression such that they will be printed after the class keyword.

`var a = class<T> extends B {}` and `export default class<T> extends B {}`
threw "Cannot read properties of undefined (reading 'getPrevSibling')":
the type parameters comment was attached to the class id, which does not
exist. Attach it to the class itself as an inner comment instead, such that
the generator prints them after the `class` keyword.

Assisted-by: Claude Opus 5.5
@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories area: flow 7.x: needs backport labels Nov 10, 2026
@babel-bot

Copy link
Copy Markdown
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/63107

@pkg-pr-new

pkg-pr-new Bot commented Nov 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

commit: 9383ec3

@JLHwung
JLHwung added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit efc15a4 Nov 10, 2026
67 checks passed
@JLHwung
JLHwung deleted the jlhwung/fix-flow-comments-anonymous-class branch November 10, 2026 18:02
@babel-bot

Copy link
Copy Markdown
Collaborator

Backported to 7.x in #18573.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: flow PR: Bug Fix 🐛 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants