Closed
Description
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have read the FAQ and my problem is not listed.
Repro
{
"rules": {
"@typescript-eslint/no-misused-promises": ["error"],
}
}
interface Props {
onEvent: (() => void) | (() => Promise<void>);
}
const Component: React.FC<Props> = () => null;
const App: React.FC = () => {
const handleEvent = async () => {};
return <Component onEvent={handleEvent} />;
};
export default App;
{
"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 since onEvent
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 in 5.14.0
. 5.13.0
ist working fine.
Note that you can circumvent the bug by using
interface Props {
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 |