-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(experimental-utils): extract isNodeOfTypeWithConditions
out of ast-utils
' predicates
#3837
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, @MichaelDeBoey! 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. |
Codecov Report
@@ Coverage Diff @@
## master #3837 +/- ##
==========================================
- Coverage 93.51% 92.65% -0.87%
==========================================
Files 151 192 +41
Lines 8144 8767 +623
Branches 2584 2694 +110
==========================================
+ Hits 7616 8123 +507
- Misses 167 260 +93
- Partials 361 384 +23
Flags with carried forward coverage won't be shown. Click here to find out more.
|
83ae194
to
d5e8fd7
Compare
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 don't think that this a "good" change.
#3677 was great because it deduplicated a bunch of types AND it also kept the same perf with the constant logical expressions.
However this change adds in several function calls (Object.entries
and Array.every
) where before there was just one logical expression - which results in code that is 98% slower - https://jsbench.me/acktt3qk8u/1.
@bradzacher We're really talking about fractions over here. The big benefit is that you don't have to declare the same thing in both return type and check, which for me is a big win in DX. The |
d5e8fd7
to
0b29c93
Compare
In isolation - yes, but these functions can be called thousands of times each over a codebase - which can add up very quickly. Let's move the |
@bradzacher What do mean exactly by this? |
0b29c93
to
76a82cc
Compare
76a82cc
to
69f47c5
Compare
… `ast-utils`' `predicates`
69f47c5
to
ebf6f45
Compare
): (( | ||
node: TSESTree.Node | null | undefined, | ||
) => node is TSESTree.Node & { type: NodeType } & Conditions) => { |
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.
Due to the extraction of entries
& @typescript-eslint/explicit-function-return-type
, we have to duplicate this return type
If you want, I can extract this into a NodeIsOfTypeWithConditionsFunction
type if you want, but this won't be much clearer I'm afraid 🤷♂️
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'm fine with the duplication on the util.
I'm also happy to just disable the linter on this check too.
We can merge this as is.
thanks for this! |
Like #3677, but with extra conditions