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

[no-misused-promises] non-thenable thenable union react component attribute does not accept thenable function #4650

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

Description

@ThiloAschebrock
  • 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

packageversion
@typescript-eslint/eslint-plugin5.14.0
@typescript-eslint/parser5.14.0
TypeScript4.6.2
ESLint8.10.0
node14.18.3

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