Repository navigation
Break after equal on assignment if rhs is await/yield expression - #15204
sosukesuzuki merged 9 commits into
Conversation
| @@ -0,0 +1,9 @@ | |||
| async function f() { | |||
There was a problem hiding this comment.
This is because Flow yields error on top-level await.
| const propertiesForPath = []; | ||
| for (;;) { | ||
| if (node.type === "UnaryExpression") { | ||
| if (node.type === "UnaryExpression" || node.type === "AwaitExpression") { |
There was a problem hiding this comment.
If we are doing this, I think we should treat yield the sameway, though it's not very common to be on RHS.
There was a problem hiding this comment.
Ah, I agree with you,thank you.
Maybe typeof too?
There was a problem hiding this comment.
I noticed typeof already breaks after =.
I try to work on yield.
| const longlonglonglonglonglonglong1 = yield qwertyuiop(asdfghjkl, zxcvbnm, qwertyuiop, asdfghjkl); | ||
| const longlonglonglonglonglonglong2 = yield { qwertyuiop: 1234567890, asdfghjkl: 1234567890, zxcvbnm: 123456789 }; | ||
|
|
||
| const x = yield; |
There was a problem hiding this comment.
I have missed it, thank you for feedback.
|
While this change is definitely the better formatting option, changing this type of formatting is a breaking change. |
commented
Aug 21, 2023
|
Definitely a breaking change since it can affect much of codebase. Is there a way to use the old way? |
|
There isn't way to avoid this on 3.0.2. ExamplesAdd parentheses for TypeofTypeAnnotation to improve readability // Input
type A = (typeof node.children)[];
// Prettier 2.8.4
type A = typeof node.children[];
// Prettier 2.8.5
type A = (typeof node.children)[];Break the LHS of type alias that has complex type parameters // Input
type FieldLayoutWith<
T extends string,
S extends unknown = { width: string }
> = {
type: T;
code: string;
size: S;
};
// Prettier 2.3.0
type FieldLayoutWith<T extends string, S extends unknown = { width: string }> =
{
type: T;
code: string;
size: S;
};
// Prettier 2.3.1
type FieldLayoutWith<
T extends string,
S extends unknown = { width: string }
> = {
type: T;
code: string;
size: S;
};Personally, I automatically format only changed files to avoid changing huge amount of files by updating Prettier. https://stackoverflow.com/q/47610213/13195622 |
Description
Works on #15196.
Feel free to stop this if it needs more discussions.
Fixes #15208
Checklist
(If changing the API or CLI) I’ve documented the changes I’ve made (in thedocs/directory).changelog_unreleased/*/XXXX.mdfile followingchangelog_unreleased/TEMPLATE.md.✨Try the playground for this PR✨