-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(experimental-utils): fix eslint-utils
' negative predicates' return types in ast-utils
#3461
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. |
12b9c08
to
3547451
Compare
While I definitely like the idea of this, ultimately this doesn't actually do anything. The type of
|
@bradzacher You think there's another way of getting the correct type then? Edit: posted https://twitter.com/MichaelDeBoey93/status/1401920255404953604 to get some help |
There is unfortunately not right now. Edit: orta dug up the issue: microsoft/TypeScript#29317 |
@bradzacher microsoft/TypeScript#29317 is the issue as mentioned by @orta in https://twitter.com/orta/status/1401934733634846723 So there's no other way to do this then? @bradzacher Making the interface PunctuatorToken extends BaseToken {
type: AST_TOKEN_TYPES.Punctuator;
value: '=>' | '}' | ']' | ')' | ':' | ',' | '{' | '[' | ...;
} |
Correct, but then we would have to attempt to list out every single possible token string and keep it up to date. Not an impossible task, just a (relatively) low value one. Also it's not a great thing because custom parsers (babel, Vue, markdown, angular) may add new tokens, which then causes our types to be wrong. By-and-large our rules shouldn't make assumptions about the parser. |
@bradzacher This PR adds type-safety and type guards for those functions. What do you think? I'm happy to create another PR to update the |
f6136c9
to
bfbf536
Compare
Nx Cloud ReportCI ran the following commands for commit 0127fc9. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch
Sent with 💌 from NxCloud. |
…urn types in `ast-utils`
@bradzacher Now that #3496 is merged, this one can be merged too I think? |
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.
yup - looks good now and it should all work!!
Just like it's done with
isNotCommentToken
typescript-eslint/packages/experimental-utils/src/ast-utils/eslint-utils/predicates.ts
Lines 49 to 51 in d4f0774