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
functionmutate(options?:{onSuccess():void}){// Just do anything with options to make TypeScript happy.console.log(options);}// This gets reported:mutate({onSuccess:async()=>{}})// This does not:mutate({asynconSuccess(){}})
ESLint Config
{"rules":{"@typescript-eslint/no-misused-promises":"error"}}
tsconfig
{"compilerOptions": {"strict":true }}(strict is turned on by default, so you don't actually need to set it to reproduce the behaviour. I just added it so it's easier to test the repro by setting it tofalse.)
Expected Result
I expected the rule to report a misused promise for both declaration styles.
I didnot expect TypeScript'sstrict compiler option to change the rule's behaviour.
Actual Result
The rule only reports theonSuccess: async () => { … } case.
Additional Info
I understand that the two styles of declaring the options object are not completely interchangeable, but I still think it's weird enough to deserve a bug report 😄
Note that this behaviouronly triggers when theoptions argument is marked optional. Declaring the function asfunction mutate(options: { … }) { … } (i.e., notoptions?: { …}) causes the rule to report the misused promise.