-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(eslint-plugin): [promise-function-async] check for promises in implicit return types #6330
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
feat(eslint-plugin): [promise-function-async] check for promises in implicit return types #6330
Conversation
Thanks for the PR, @ericbf! 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 site settings. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6330 +/- ##
==========================================
- Coverage 90.61% 90.59% -0.03%
==========================================
Files 372 372
Lines 12709 12712 +3
Branches 3739 3743 +4
==========================================
Hits 11516 11516
- Misses 853 856 +3
Partials 340 340
Flags with carried forward coverage won't be shown. Click here to find out more.
|
3527630
to
c65b905
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.
overall the changes look good - but we'll need to ensure we're not breaking the API
When we return a union containing a promise from a function implicitly, it's often a mistake. This commit makes it so if the return type is explicit, any `Promise` in the return type (whether it's part of a union or not) will flag the function. If it is intentional, make the return type explicit. Fixes typescript-eslint#6329
c30bf71
to
be9531d
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.
thanks for this!
When we return a union containing a promise from a function implicitly, it's often a mistake. This commit makes it so if the return type is explicit, any
Promise
in the return type (whether it's part of a union or not) will flag the function. If it is intentional, make the return type explicit.Fixes #6329
PR Checklist
async
functions returning unions with non-Promise
types #6329Overview
This implements the heuristic that @bradzacher suggested. If the return type is explicit, it allows unions with non-
Promise
types, but if it is implicit, it flags those.