-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: merge AST structure of TSAsExpression with TSTypeAssertion #3005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for the PR, @armano2! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day. |
if (node.kind === 'as') { | ||
this.visit(node.expression); | ||
this.visitType(node.typeAnnotation); | ||
} else { | ||
this.visitType(node.typeAnnotation); | ||
this.visit(node.expression); | ||
} |
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.
while doing this change i noticed that order of creating references was not correct
Codecov Report
@@ Coverage Diff @@
## master #3005 +/- ##
==========================================
- Coverage 92.87% 92.85% -0.02%
==========================================
Files 314 314
Lines 10670 10671 +1
Branches 3026 3029 +3
==========================================
- Hits 9910 9909 -1
Misses 344 344
- Partials 416 418 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
node.type === AST_NODE_TYPES.TSTypeAssertion && | ||
node.kind === 'as' |
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.
there is no unit case for type assertion with brackets
i implemented this change but I'm unsure if this is actually good |
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 implemented this change but I'm unsure if this is actually good
What do you mean?
Do you mean you don't like having one node represent the two different types?
TSTypeAssertion(node): void { | ||
if (node.kind !== 'as') { | ||
return; | ||
} |
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.
could do this via a selector
TSTypeAssertion(node): void { | |
if (node.kind !== 'as') { | |
return; | |
} | |
'TSTypeAssertion[kind = "as"]'(node): void { |
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.
we could also add this as a typed selector to packages/types/src/ast-node-types.ts
as it's probably going to be a more common usecase
yes, I'm not sure if this is a good change, for sure its more convenient |
THIS IS BREAKING CHANGE
8233a9b
to
16a89b1
Compare
This PR aims to merge AST structure of
TSAsExpression
withTSTypeAssertion
This is BREAKING CHANGE
New AST structure
TODO:
indent
rulekeyword-spacing
ruleno-var-requires
rulefixes #2142