-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix(eslint-plugin): [no-unnecessary-type-assertion] correct handling of undefined vs. void #11826
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
fix(eslint-plugin): [no-unnecessary-type-assertion] correct handling of undefined vs. void #11826
Conversation
…rtion handling for IIFE and add related tests
|
Thanks for the PR, @Tamashoo! 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. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
View your CI Pipeline Execution ↗ for commit 929ad00
☁️ Nx Cloud last updated this comment at |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11826 +/- ##
==========================================
+ Coverage 90.53% 90.59% +0.05%
==========================================
Files 523 524 +1
Lines 53096 53410 +314
Branches 8838 8918 +80
==========================================
+ Hits 48073 48385 +312
- Misses 5010 5012 +2
Partials 13 13
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
JoshuaKGoldberg
left a comment
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.
This is looking good, thanks for the PR! I poked at the rule in a bunch of different ways and couldn't figure out amy way to break the new implementation. Nice work 🙂.
Just requesting changes on more thorough testing. This area of TypeScript (inferred types, overloads/signatures) tends to cause bugs in lint rules a lot.
packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts
Show resolved
Hide resolved
|
@JoshuaKGoldberg I’ve added the minimal test cases you suggested and fixed the existing tests. If you have any further thoughts on edge cases worth covering, please let me know. |
JoshuaKGoldberg
left a comment
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.
🙌 wonderful, thanks!
46171f0
into
typescript-eslint:main

PR Checklist
voidreturn type toundefined#11529Overview
Added special handling for type checking of IIFEs in the no-unnecessary-type-assertion rule.
Introduced an isIIFE type guard and a getUncastType helper function to correctly resolve IIFE return types, converting implicit undefined to void for functions without explicit return type annotations.
This improves the accuracy of unnecessary assertion detection for IIFE expressions.