Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print trailing comma for type parameters #10109

Conversation

sosukesuzuki
Copy link
Member

@sosukesuzuki sosukesuzuki commented Jan 23, 2021

Description

Fixes #3662.

I think we can do this at next major.

Checklist

  • I’ve added tests to confirm my change works.
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@thorn0
Copy link
Member

thorn0 commented Jan 26, 2021

TS 2.7 was released 3 years ago. I don't think we need a major version for this.

Copy link
Member

@thorn0 thorn0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic relies on the file extension (isTSXFile), so I can't reproduce this on the playground:

test-tsx.tsx:

const f = <Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt, >() => 1
$ prettier test-tsx.tsx --trailing-comma all
const f = <
  Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt,,
>() => 1;

See also #3662 (comment)

BTW, this also means that Prettier has been outputting code with trailing commas in type parameters for a while already, at least for TSX. so this change is definitely safe for a non-major version.

@sosukesuzuki sosukesuzuki force-pushed the print-trailing-comma-for-type-parameter branch from f465e6c to d046790 Compare January 27, 2021 08:28
@sosukesuzuki sosukesuzuki changed the base branch from next to main January 27, 2021 08:29
@sosukesuzuki sosukesuzuki merged commit 53a7e97 into prettier:main Jan 28, 2021
@sosukesuzuki sosukesuzuki deleted the print-trailing-comma-for-type-parameter branch January 28, 2021 14:03
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trailing commas for type parameters in TypeScript
3 participants