Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I havesearched for related issues and found none that matched my issue.
- I haveread the FAQ and my problem is not listed.
Playground Link
Repro Code
asyncfunctionfn(){awaitPromise.reject(3).finally(async()=>{});}
ESLint Config
module.exports={parser:"@typescript-eslint/parser",rules:{"@typescript-eslint/no-misused-promises":"error"},};
tsconfig
{"exclude": ["**/node_modules"],"compilerOptions": {"target":"ES2022","useDefineForClassFields":true,"module":"ES2022","moduleResolution":"node","resolveJsonModule":true,"allowJs":true,"checkJs":true,"declaration":true,"declarationMap":true,"sourceMap":true,"removeComments":true,"importHelpers":true,"downlevelIteration":true,"newLine":"LF","isolatedModules":true,"verbatimModuleSyntax":true,"allowSyntheticDefaultImports":true,"esModuleInterop":true,"forceConsistentCasingInFileNames":true,"strict":true,"noUnusedLocals":false,"noUnusedParameters":false,"exactOptionalPropertyTypes":true,"noImplicitReturns":true,"noFallthroughCasesInSwitch":true,"noUncheckedIndexedAccess":true,"noImplicitOverride":true,"noPropertyAccessFromIndexSignature":true,"allowUnusedLabels":false,"allowUnreachableCode":false,"skipLibCheck":true}}
Expected Result
OK
Actual Result
Promise returned in function argument where a void return was expected @typescript-eslint/no-misused-promises
Additional Info
This is a request to re-consider#7276.
The issue was closed with reference to the type definition of theonFinally
callback:
interfacePromise<T>{finally(onfinally?:(()=>void)|undefined|null):Promise<T>}
However,the type definition is erroneous and Microsoft has declined to fix it.
Based on the type definition,@bradzacher closed the issue because,
The rule is simply warning you that you're passing an async function into a place that won't handle the promise.
But the place in questiondoes handle the promise:
A function to asynchronously execute when this promise becomes settled. Its return value is ignoredunless the returned value is a rejected promise. The function is called with no arguments.
It's unfortunate this problem has come to typescript-eslint from upstream, but please reopen#7276 until a solution can be found.