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 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
Repro Code
function getInnerValue(...args: readonly []): undefined;
function getInnerValue(...args: readonly [string]): undefined;
function getInnerValue(..._args: readonly string[]): undefined {
return undefined;
}
export function getValue(): undefined {
return getInnerValue('a');
}
ESLint Config
{
"rules": {
"@typescript-eslint/no-misused-promises": [
"error",
{
"checksVoidReturn": {
"attributes": false
}
}
]
}
}
tsconfig
Expected Result
eslint runs without error
Actual Result
TypeError: Cannot read properties of undefined (reading 'flags')
Occurred while linting <input>:8
Rule: "@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:
function getInnerValue(...args: readonly []): undefined;
function getInnerValue(...args: readonly [string]): undefined;
function getInnerValue(..._args: readonly string[]): undefined {
return undefined;
}
export function getValue(): undefined {
return getInnerValue('a');
}
But this does not:
function getInnerValue(args: readonly []): undefined;
function getInnerValue(args: readonly [string]): undefined;
function getInnerValue(_args: readonly string[]): undefined {
return undefined;
}
export function getValue(): undefined {
return getInnerValue(['a']);
}
And neither does this:
function getInnerValue(...args: readonly string[]): undefined {
return undefined;
}
export function getValue(): undefined {
return getInnerValue('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 |