Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed
Description
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I haveread the FAQ and my problem is not listed.
Repro
{"rules": {"@typescript-eslint/no-misused-promises": ["error"], }}
interfaceProps{onEvent:(()=>void)|(()=>Promise<void>);}constComponent:React.FC<Props>=()=>null;constApp:React.FC=()=>{consthandleEvent=async()=>{};return<ComponentonEvent={handleEvent}/>;};exportdefaultApp;
{"compilerOptions": {"target":"ESNext","useDefineForClassFields":true,"lib": ["DOM","DOM.Iterable","ESNext"],"allowJs":false,"skipLibCheck":false,"esModuleInterop":false,"allowSyntheticDefaultImports":true,"strict":true,"forceConsistentCasingInFileNames":true,"module":"ESNext","moduleResolution":"Node","resolveJsonModule":true,"isolatedModules":true,"noEmit":true,"jsx":"react-jsx" },"include": ["src"],"references": [{"path":"./tsconfig.node.json" }]}
Expected Result
No linting error sinceonEvent
accepts both a thenable and a non-thenable function.
Actual Result
9:29 error Promise-returning function provided to attribute where a void return was expected @typescript-eslint/no-misused-promises`
Additional Information
This bug was introduced in5.14.0
.5.13.0
ist working fine.
Note that you can circumvent the bug by using
interfaceProps{onEvent:()=>void|Promise<void>;}
instead.
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin | 5.14.0 |
@typescript-eslint/parser | 5.14.0 |
TypeScript | 4.6.2 |
ESLint | 8.10.0 |
node | 14.18.3 |