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] Cannot read properties of undefined (reading 'flags') #5807

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

Description

@jlowcs

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=4.8.4&sourceType=module&code=GYVwdgxgLglg9mABAcwKZQJJjKgTgNQEMAbEVACgDprDdkBnALkV1UIBMFiBPRAbQC6ASmbh2qYDBzsA3AChQkWAhTosOAiTJUadJizacwPfvSi4pyYaLDjJ0+YujwkaTNjxFSFapQD6tAzMrBxcvGYWYMiCIohiElKo7IgA3nKIBlAguEjx9knyAL5ycqgAHgAOcLhQiE7Kruhe2rF5iclpGaxZOaruGs0UAOSEQ0JFQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1oFtLlZkiACa1i0Dr0GoMAbXDYciaOOiQANPIVYF2SGQAWiMgGtkANQ6UhAJUT5Y0JukyadOAIb58VAEax8KM4AZu7wgq4KAL4RYNEKALry0ZFAA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

functiongetInnerValue(...args:readonly[]):undefined;functiongetInnerValue(...args:readonly[string]):undefined;functiongetInnerValue(..._args:readonlystring[]):undefined{returnundefined;}exportfunctiongetValue():undefined{returngetInnerValue('a');}

ESLint Config

{"rules":{"@typescript-eslint/no-misused-promises":["error",{"checksVoidReturn":{"attributes":false}}]}}

tsconfig

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

Expected Result

eslint runs without error

Actual Result

TypeError: Cannot read properties of undefined (reading 'flags')Occurred while linting <input>:8Rule: "@typescript-eslint/no-misused-promises"    at SU.isUnionType (https://typescript-eslint.io/sandbox/index.js:20:512744)    at Object.c [as unionTypeParts] (https://typescript-eslint.io/sandbox/index.js:20:515201)    at https://typescript-eslint.io/sandbox/index.js:20:893906    at m2 (https://typescript-eslint.io/sandbox/index.js:20:893955)    at https://typescript-eslint.io/sandbox/index.js:20:900093    at d (https://typescript-eslint.io/sandbox/index.js:20:900175)    at https://typescript-eslint.io/sandbox/index.js:20:258820    at https://typescript-eslint.io/sandbox/index.js:20:249337    at Array.forEach (<anonymous>)    at Object.emit (https://typescript-eslint.io/sandbox/index.js:20:249325)

Additional Info

The issue seems to be coming from the function being defined in a polymorphism manner with rest args.

For instance, this produces the error:

functiongetInnerValue(...args:readonly[]):undefined;functiongetInnerValue(...args:readonly[string]):undefined;functiongetInnerValue(..._args:readonlystring[]):undefined{returnundefined;}exportfunctiongetValue():undefined{returngetInnerValue('a');}

But this does not:

functiongetInnerValue(args:readonly[]):undefined;functiongetInnerValue(args:readonly[string]):undefined;functiongetInnerValue(_args:readonlystring[]):undefined{returnundefined;}exportfunctiongetValue():undefined{returngetInnerValue(['a']);}

And neither does this:

functiongetInnerValue(...args:readonlystring[]):undefined{returnundefined;}exportfunctiongetValue():undefined{returngetInnerValue('a');}

Versions

packageversion
@typescript-eslint/eslint-plugin5.40.0
@typescript-eslint/parser5.40.0
TypeScript4.8.4
ESLint8.15.0
node18.9.1

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