Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed
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
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
package | version |
---|---|
@typescript-eslint/eslint-plugin | 5.40.0 |
@typescript-eslint/parser | 5.40.0 |
TypeScript | 4.8.4 |
ESLint | 8.15.0 |
node | 18.9.1 |