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

Improve formatting for empty tuple types #11884

Merged
merged 8 commits into from Nov 30, 2021

Conversation

sosukesuzuki
Copy link
Member

@sosukesuzuki sosukesuzuki commented Nov 30, 2021

Description

Fixes #11878

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

Co-authored-by: fisker Cheung <lionkay@gmail.com>
node[typesField].length > 0 &&
getLast(node[typesField]).type === "TSRestType";
const types = node[typesField];
const isNotEmptyTuple = isNonEmptyArray(types);
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Let's use isNonEmptyTuple or just isNonEmpty to keep consistent with the function name?

@sosukesuzuki sosukesuzuki merged commit e17404e into prettier:main Nov 30, 2021
@sosukesuzuki sosukesuzuki deleted the fix-11878 branch November 30, 2021 14:48
sosukesuzuki added a commit that referenced this pull request Dec 4, 2021
* Don't print trailing comma when tuple is empty

* Add tests

* Don't print softline

* Add tests

* Update tests

* Add changelog

* Update changelog_unreleased/typescript/11884.md

Co-authored-by: fisker Cheung <lionkay@gmail.com>

* Fix names

Co-authored-by: fisker Cheung <lionkay@gmail.com>
@@ -0,0 +1,32 @@
#### Improve formatting for empty tuple types (#11884 by @sosukesuzuki)

Choose a reason for hiding this comment

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

.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2023
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.

When formatting TypeScript generics, a comma was incorrectly inserted in the empty array.
3 participants