Skip to content

Bug: SpreadElement does not allow NewExpression parent #10023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks done
eventualbuddha opened this issue Sep 19, 2024 · 0 comments · Fixed by #10024
Closed
4 tasks done

Bug: SpreadElement does not allow NewExpression parent #10023

eventualbuddha opened this issue Sep 19, 2024 · 0 comments · Fixed by #10024
Labels
bug Something isn't working locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. triage Waiting for team members to take a look

Comments

@eventualbuddha
Copy link
Contributor

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

https://typescript-eslint.io/play/#ts=5.5.2&showAST=es&fileType=.tsx&code=HYUw7gBAggTjCGBPAFAOnQbQLoEog&eslintrc=N4KABGBEBOCuA2BTAzpAXGYBfEWg&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

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:

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
@eventualbuddha eventualbuddha added bug Something isn't working triage Waiting for team members to take a look labels Sep 19, 2024
@github-actions github-actions bot added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Sep 27, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. triage Waiting for team members to take a look
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant