-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(eslint-plugin): [no-misused-promises] check contextual type #10042
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, @yeonjuan! 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 configuration. |
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 107a125. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 2 targetsSent with 💌 from NxCloud. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10042 +/- ##
==========================================
+ Coverage 88.69% 88.73% +0.04%
==========================================
Files 426 426
Lines 14829 14884 +55
Branches 4313 4328 +15
==========================================
+ Hits 13153 13208 +55
- Misses 1533 1534 +1
+ Partials 143 142 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
const contextualType = checker.getContextualTypeForArgumentAtIndex( | ||
node, | ||
index, | ||
); | ||
if (contextualType !== type) { | ||
checkThenableOrVoidArgument( | ||
checker, | ||
node, | ||
contextualType, | ||
index, | ||
thenableReturnIndices, | ||
voidReturnIndices, | ||
); | ||
} |
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.
[Bug] We should also do this both for arrays and tuples
declare function fn<T extends (...args: unknown[]) => unknown>(fn: T): void
fn<() => void>(async () => { }); // reported - ok
declare function tupleFn<T extends (...args: unknown[]) => unknown>(...fns: [T, string, T]): void
tupleFn<() => void>(async () => { }, 'foo', async () => { }); // not reported - bug
declare function arrayFn<T extends (...args: unknown[]) => unknown>(...fns: (T | string)[]): void
arrayFn<() => void>(async () => { }, 'foo', async () => { }); // not reported - bug
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.
fn: T, | ||
) => T; | ||
declare const useCallbackReturningVoid: typeof useCallback<ReturnsVoid>; | ||
useCallbackReturningVoid(async () => {}); // correct |
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.
useCallbackReturningVoid(async () => {}); // correct | |
useCallbackReturningVoid(async () => {}); |
nit :)
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.
LGTM, thanks!
PR Checklist
Overview