Improve formatting for constraints on type parameters#14858
Improve formatting for constraints on type parameters#14858fisker merged 4 commits intoprettier:mainfrom
Conversation
| const groupId = Symbol("constraint"); | ||
| parts.push( | ||
| " extends", | ||
| group(indent(line), { id: groupId }), | ||
| lineSuffixBoundary, | ||
| indentIfBreak(print("constraint"), { groupId }) | ||
| ); |
There was a problem hiding this comment.
prettier/src/language-js/print/assignment.js
Lines 53 to 62 in 2a864e5
| LongerLongerLongerLongerInnerType extends | ||
| LongerLongerLongerLongerLongerLo | ngerLongerLongerOtherType, | ||
| | LongerLongerLongerLongerLongerLo | ||
| | ngerLongerLongerOtherType, |
There was a problem hiding this comment.
Should we keep the extends part inline?
Prettier pr-14858
Playground link
--parser typescriptInput:
export type OuterType4<
LongerLongerLongerLongerInnerTypeLongerLongerLongerLongerInnerType extends
A | B,
> = { a: 1 };Output:
export type OuterType4<
LongerLongerLongerLongerInnerTypeLongerLongerLongerLongerInnerType extends
| A
| B,
> = { a: 1 };There was a problem hiding this comment.
Ideally, yes? But current main outputs this code, so if we address this, it should be addressed as other issue.
Prettier 2.8.8
Playground link
--parser typescriptInput:
export type OuterType4<
LongerLongerLongerLongerInnerTypeLongerLongerLongerLongerInnerType extends
A | B,
> = { a: 1 };Output:
export type OuterType4<
LongerLongerLongerLongerInnerTypeLongerLongerLongerLongerInnerType extends
| A
| B
> = { a: 1 };There was a problem hiding this comment.
But we changed output of this test.(line 407 in this file) The original didn't break things after extends.
There was a problem hiding this comment.
I don't think that should be a concern here. Because "original" means current main branch and there is no change from the 2.8.8 behavior. So this is a different issue.
|
I'll release a new alpha version. |
Description
Fixes #14809
Fixes #14808
It uses the same logic as the "fluid" layout of the assignment.
This changes some behavior that is not related to the original issue, such as the
lineSuffixBoundarycomment.Checklist
docs/directory).changelog_unreleased/*/XXXX.mdfile followingchangelog_unreleased/TEMPLATE.md.✨Try the playground for this PR✨