You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This proposal is to add a parenthesis type for expressions. This was slightly mentioned in the CST issue but I think this is much more basic, hence splitting it out into it's own issue.
Issue
Note: yes this is very contrived and will always result in the same value but it's trimmed down for this example:
let value = (2) | 1;
The trimmed down output of this without a parenthesized type is:
which means the context of the parenthesis is missing. This means if you were to reprint this document, you have no context as to where a user may or may not have added parenthesis to break up expressions.
For me, I'm writing a cli that helps order code so losing the context of the parenthesis means that my code now reorders this binary expression like this
let value = (1) | 2;
Which isn't what the developer initially intended
Proposal
Adding a ParenthesizedType will allow for the context of the parenthesis to be conveyed in the AST
This proposal is to add a parenthesis type for expressions. This was slightly mentioned in the CST issue but I think this is much more basic, hence splitting it out into it's own issue.
Issue
Note: yes this is very contrived and will always result in the same value but it's trimmed down for this example:
The trimmed down output of this without a parenthesized type is:
which means the context of the parenthesis is missing. This means if you were to reprint this document, you have no context as to where a user may or may not have added parenthesis to break up expressions.
For me, I'm writing a cli that helps order code so losing the context of the parenthesis means that my code now reorders this binary expression like this
Which isn't what the developer initially intended
Proposal
Adding a ParenthesizedType will allow for the context of the parenthesis to be conveyed in the AST
Credit to where credit is due, I got this idea from TSParenthesizedType from typescript-estree
The text was updated successfully, but these errors were encountered: