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
types
Playground Link
Repro Code
import {
AST_NODE_TYPES,
ESLintUtils,
TSESTree,
} from '@typescript-eslint/utils';
export const listener: ESLintUtils.RuleListener = {
SpreadElement(node: TSESTree.SpreadElement): void {
switch (node.parent.type) {
case AST_NODE_TYPES.NewExpression: {
break;
}
}
},
};
ESLint Config
No response
tsconfig
No response
Expected Result
I expect that comparing node.parent.type
to AST_NODE_TYPES.NewExpression
to be allowed when node
is TSESTree.SpreadElement
, but it isn't because TypeScript errors.
Actual Result
I get this error from TypeScript:
Type 'AST_NODE_TYPES.NewExpression' is not comparable to type 'AST_NODE_TYPES.ArrayExpression | AST_NODE_TYPES.CallExpression | AST_NODE_TYPES.ObjectExpression'. ts(2678)
Additional Info
A couple similar but not identical issues related to this:
- Bug: NewExpression doesn't allow SpreadElement as argument #5421
ArrayExpression
does not includeSpreadElement
as possible value of elements property #4963
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
8.6.0 |
@typescript-eslint/parser |
8.6.0 |
@typescript-eslint/rule-tester |
8.6.0 |
@typescript-eslint/scope-manager |
8.6.0 |
@typescript-eslint/typescript-estree |
8.6.0 |
@typescript-eslint/type-utils |
8.6.0 |
@typescript-eslint/utils |
8.6.0 |
TypeScript |
5.5.3 |
ESLint |
8.57.0 |
node |
20.16.0 |