Skip to content

Bug: [no-misused-promises] false positive with non-promise returning function in JSX #6637

Closed
@bradzacher

Description

@bradzacher

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 have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=4.9.3&jsx=true&sourceType=module&code=JYOwLgpgTgZghgYwgAgMoQDYQZAJgBQHsBnYMYQkZAbwChlkNQIAuZEAVwFsAjaAbnrIEhDNxBtOvAbQC+tWqEixEKdFhwRcAJTggA5ijoNiYOFDBt12PEVLlKghhBC4rmG1rtkKIQfLAATwAHFAB5EGscADlCXAgAMSoAXmQAChA41jQPTR09Q2QAH3YODAwASmRkgD5kADdCYFxBRXBoeCRkAEFUABUANWAIAHdoACE4Ygh8KEJg4hohKAg4XEoMQORKKLBY+IB+Ngjd-cS-OQV4hAxzFBgOEBxfHv6h0eg04LmFtl7B4ZjKCTaazebECqSMoYQTXW4rYSUUzbSK5MBJY6ojR7LJJVppAA8-3eQKEOzRZ2S1HJ2KS8gA9DUKq0gA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1oFtLlZkiACa1i0Dr0GoMkRNHHRI4MAF8QKoA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

type OnSelectNodeFn = (node: string | null) => void;

interface ASTViewerBaseProps {
  readonly onSelectNode?: OnSelectNodeFn;
}

declare function ASTViewer(props: ASTViewerBaseProps): null;
declare const onSelectFn: OnSelectNodeFn;

(<ASTViewer
  onSelectNode={onSelectFn}
/>);

ESLint Config

module.exports = {
  "rules": {
    "@typescript-eslint/no-misused-promises": "error"
  }
}

tsconfig

{
  "compilerOptions": {
    "strictNullChecks": true
  }
}

Expected Result

No error because the property is a void-returning function and the passed variable is exactly the same type

Actual Result

No error

Additional Info

No response

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