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.
Relevant Package
typescript-estree
Playground Link
Repro Code
import { TSESTree } from '@typescript-eslint/utils';
function loopOverElements(array: TSESTree.ArrayExpression) {
for (const elem of array.elements) {
// Handle cases like const a = [...b];
if (elem.type === "SpreadElement") break;
// do something for the expression
}
}
ESLint Config
No response
tsconfig
No response
Expected Result
The elem
variable should have a type of TSESTree.Expression | TSESTree.SpreadElement
and the code above should typecheck.
Actual Result
The elem
variable has a type of TSESTree.Expression
and the code above doesn't typecheck because the type of elem.type
doesn't intersect with "SpreadElement"
.
Additional Info
No response
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
5.23.0 |
@typescript-eslint/parser |
5.23.0 |
@typescript-eslint/scope-manager |
5.23.0 |
@typescript-eslint/typescript-estree |
5.23.0 |
@typescript-eslint/type-utils |
5.23.0 |
@typescript-eslint/utils |
5.23.0 |
TypeScript |
4.6.4 |
ESLint |
8.15.0 |
node |
16.10.0 |