[RFC] unify type assertion nodes #6021
Replies: 3 comments
-
You know, in retrospect, I don't think there was a need to convert this into a discussion 😄. We like this. And now there's no way to re-open the existing issue. Ah well. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Worth noting that now we have |
Beta Was this translation helpful? Give feedback.
0 replies
-
Moved to #6099 🚀 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There are two styles for type-assertions:
as
assertions (x as type
)<type>x
)Currently they produce two different, but almost identical ASTs:
and
I don't think that there's a reason why these should be separate AST nodes. I think that they're separate nodes because they have different code representations, but I don't know if that's something that matters from the POV of the AST. Similar to the discussion that's going on around the ESTree representation of optional chaining - there is a difference between the AST and the CST.
From the perspective of ESLint, having two nodes causes pains when writing lint rules, as authors have to remember to add both nodes to selectors or
if
checks. Often they don't, which means rules don't have proper support for TS syntax.I propose that we unify the two nodes with the following AST:
Beta Was this translation helpful? Give feedback.
All reactions