Skip to content

Fix unstable comments before generic function type parameters - #20374

Open
Arham-Begani wants to merge 2 commits into
prettier:mainfrom
Arham-Begani:fix/typescript-generic-comment-idempotency
Open

Arham-Begani wants to merge 2 commits into
prettier:mainfrom
Arham-Begani:fix/typescript-generic-comment-idempotency

Conversation

@Arham-Begani

@Arham-Begani Arham-Begani commented Oct 26, 2026 •

Copy link
Copy Markdown

Description

Fixes #9570. A comment between a function's name and its type parameters attached to different nodes depending on surrounding line breaks. Formatting therefore changed its own output on subsequent passes.

Keep these comments attached to the type parameters in all three comment placements, and print a separating space after the function name. The change covers named function declarations and expressions, including TypeScript ambient declarations. Anonymous functions and non-generic functions retain their existing handling.

The regression fails on the parent: four repeat-format checks fail. With the fix, the JavaScript/TypeScript/Flow run passes 72,932 tests across 1,037 suites under FULL_TEST=1, including AST and repeat-format checks. After adding Flow coverage and renaming the private node guard, the final focused run passes 183 tests without updating snapshots. Type checking, focused ESLint and formatting checks pass on Node 24.19.0 with the pinned Yarn 4.18.1.

This implementation, analysis and description were prepared with OpenAI Codex assistance. The contributor personally reviewed the implementation and tests, confirmed understanding and ability to explain them, and authorized submission.

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory). No API or CLI change.
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md. Added changelog_unreleased/typescript/20374.md after PR creation, as CONTRIBUTING.md specifies.
  • I’ve read the contributing guidelines.
  • I have reviewed the AI-generated content before submitting.

Upstream Actions on ab350738669c8ab84cf90825b479053456c34dc8 have not executed yet: Dev, Prod, Lint, Check Sizes and autofix.ci await maintainer authorization. Local results above are separate from upstream validation.

Keep comments between a named function and its type parameters attached to the type parameters across formatting passes, and print the separating space. Add repeat-format and parser-consistency coverage for TypeScript and Flow.

Fixes prettier#9570
@netlify

netlify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for prettier ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit ab35073
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/6adf84b14040f5b6825a2888
😎 Deploy Preview https://deploy-preview-20374--prettier.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Record the TypeScript and Flow behavior correction for prettier#20374, with the verified Prettier 3.9.9 before/after example.
@Arham-Begani
Arham-Begani marked this pull request as ready for review October 26, 2026 16:51
@Arham-Begani

Copy link
Copy Markdown
Author

The final head is ab350738669c8ab84cf90825b479053456c34dc8. Its follow-up commit adds only the numbered release note; the reviewed implementation and tests are unchanged from c3060fc.

The current Dev, Prod, Lint, Check Sizes and autofix.ci workflows are awaiting fork-CI authorization. Could a maintainer approve these runs when convenient? The PR description records the local regression evidence, 72,932-test broad run and final focused checks; no upstream test pass is claimed.

This status update was prepared with AI assistance, as disclosed in the PR.

@Arham-Begani

Copy link
Copy Markdown
Author

Following up on ab35073. Could a maintainer approve the pending fork-CI runs and review the generic function type comment fix when convenient?

The implementation is unchanged, and the branch merges cleanly with current main. Please let me know if an additional regression case or scope adjustment would help.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-idempotent whitespace with comment around type parameter.

1 participant