Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
feat(eslint-plugin): [no-unnecessary-condition] flag unnecessary type predicates based on assignability#11735
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. If I replace this entire diff with - if (typeOfArgument === typeGuardAssertedArgument.type) {+ if (+ checker.isTypeAssignableTo(+ typeOfArgument,+ typeGuardAssertedArgument.type,+ )+ ) { (which is what was intended in#11716 (comment)), the only test case that doesn't pass (apart from spurious reasons) is functionprocessArray(arr:readonlystring[]){if(Array.isArray(arr)){returnarr.length;}} So, I'm still thinking that changing to the assignability API makes sense, at least as a first step. In other words, let's take on the assignability API change before worrying about the edge case of Also cc@ronami There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Done! Changed to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. @azat-io almost! I really mean the entire diff, though, not just the Array.isArray case. The thought is to change all unnecessary type predicate detection to be based on assignability. Note that this change would require accompanying report message changes and additional testing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Done! Changed to use |
Uh oh!
There was an error while loading.Please reload this page.