Skip to content

fix(typescript): remove extra trailing comma in generic arrow functions#19011

Closed
ljjunh wants to merge 2 commits intoprettier:mainfrom
ljjunh:fix/ts-generic-arrow-function-trailing-comma
Closed

fix(typescript): remove extra trailing comma in generic arrow functions#19011
ljjunh wants to merge 2 commits intoprettier:mainfrom
ljjunh:fix/ts-generic-arrow-function-trailing-comma

Conversation

@ljjunh
Copy link
Copy Markdown

@ljjunh ljjunh commented Apr 6, 2026

Description

Fixes #18997

shouldForceTrailingComma in src/language-js/print/type-parameters.js was using a negative check
!(options.filepath && /\.ts$/.test(options.filepath)), which incorrectly added a trailing comma to generic
arrow functions when no filepath was provided (e.g., via API or playground).

The trailing comma <T,> is only needed in .tsx/.jsx files to prevent <T> from being misidentified as a
JSX tag. Changed the condition to explicitly check for JSX-capable file extensions.

Checklist

  • [ x ] 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).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • [ x ] I’ve read the contributing guidelines.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 6, 2026

Deploy Preview for prettier ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 2f058b8
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/69d3bb7af20f530008f41bd2
😎 Deploy Preview https://deploy-preview-19011--prettier.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 6, 2026

Deploy Preview for prettier ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit cc363f4
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/69d3bbb6c5e7c20009e3f0c4
😎 Deploy Preview https://deploy-preview-19011--prettier.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@fisker
Copy link
Copy Markdown
Member

fisker commented Apr 10, 2026

#18997 (comment)

@fisker fisker closed this Apr 10, 2026
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.

Arrow function with generics has extra comma in list of generic identifier

2 participants