Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug: [no-misused-promises] Specific function declaration syntax circumvents the rule with TypeScriptstrict enabled #11699

Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
@theneva

Description

@theneva

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

https://typescript-eslint.io/play/#ts=5.9.3&fileType=.tsx&code=GYVwdgxgLglg9mABAWxFAhlApgCjgB1gQGcB%2BALkQG9EEBlECCLY4nASkoDc4YATRAF921AFCJEAekmIAUiGJREfOInRgAnlAAWMMAHNEAdxg7aheGGKIoq5OgDWWRABUN%2BLHQgAnGIUTa6Pj4GgB04ogQJHAANlihMXD6eBYk7ADcooKiotKuutb6WFDW3lj4cN7YfOGoGNg4NPSMzKyU6MQakIgciAC8AHzUQkLsOXkuBcpwLIhgcFC1aJi4NB1dELRgDEwsbCI0gqOiQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1oFtLlZkiACa1i0Dr0GoMkRNHHRI4MAF8QKoA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eFYDAruuGAL4g9A&tokens=false

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp