Skip to content

Print trailing comma for type parameters - #10109

Merged
sosukesuzuki merged 8 commits into
prettier:mainfrom
sosukesuzuki:print-trailing-comma-for-type-parameter
Jan 28, 2021
Merged

sosukesuzuki merged 8 commits into
prettier:mainfrom
sosukesuzuki:print-trailing-comma-for-type-parameter

Conversation

@sosukesuzuki

@sosukesuzuki sosukesuzuki commented Jan 23, 2021 •

Copy link
Copy Markdown
Member

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

thorn0 commented Jan 26, 2021

Copy link
Copy Markdown
Member

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

@thorn0 thorn0 left a comment

Copy link
Copy Markdown
Member

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 requested a review from fisker January 28, 2021 13:41
@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