This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 656
feat(rome_js_formatter): type alias as assignment like #2787
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ematipico
force-pushed
the
feature/type-alias-declaration
branch
from
June 27, 2022 14:36
c9035cc
to
a606eee
Compare
denbezrukov
reviewed
Jun 27, 2022
semicolon_token, | ||
} = node.as_fields(); | ||
|
||
let type_token = node.type_token()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does type_token
belong to 'left' in JsAnyAssigmentLike
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I maintained the same logic we have introduced for variable declarations. There, the kind
(var/let/const) doesn't belong to left. Hence, here type_token
doesn't belong to left.
leops
approved these changes
Jun 28, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This adds
TsTypeAliasDeclaration
to the list of assignment like expressions. Part of #2424It also adds some additional condition, around this new variant, for the
BreakLeftHandSide
.I had to change a bit how
should_break_after_operator
is used. The function accepts aJsAnyExpression
, but with TS we have a right hand side that is not an expression. So I just created a thin wrapper to callhas_new_line_before_comment
for every right node.At the moment there's a small regression around the indentation of type unions, that's because at the moment these unions are not formatted as a binary like expression.
I will make a separate PR to include them in the
JsAnyBinaryLikeExpression
union.I also took the liberty to merge the formatting logic of
JsObjectExpression
andTsObjectType
into a new union type. This will make sure that we don't diverge too much, and if we need to fix some logic, it's applied to both nodes.Test Plan
Current test suite, and checked that the new snapshots are correct.
PR
File Based Average Prettier Similarity: 76.38%
Line Based Average Prettier Similarity: 71.92%
main
File Based Average Prettier Similarity: 76.34%
Line Based Average Prettier Similarity: 71.91%