Skip to content

Bug: wrong ImportAttribute#parent type #10254

@ota-meshi

Description

@ota-meshi

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

ast-spec

Playground Link

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

Repro Code

Looking at the source code, the types are currently defined as follows:

  interface ImportAttribute {
    parent: TSESTree.ImportDeclaration | TSESTree.ImportExpression;
  }

parent: TSESTree.ImportDeclaration | TSESTree.ImportExpression;

However, I think the correct way to follow ESTree is as follows:

  interface ImportAttribute {
-    parent: TSESTree.ImportDeclaration | TSESTree.ImportExpression;
+    parent: TSESTree.ImportDeclaration | TSESTree. ExportNamedDeclaration | TSESTree. ExportAllDeclaration;
  }

https://github.com/estree/estree/blob/master/es2025.md

What do you think?

ESLint Config

module.exports = {
  /* This is not necessary. */
};

tsconfig

{
  "compilerOptions": {
    // This is not necessary.
  }
}

Expected Result

I think ImportAttribute#parent needs to be TSESTree.ImportDeclaration | TSESTree. ExportNamedDeclaration | TSESTree. ExportAllDeclaration.

Actual Result

Currently, ImportAttribute#parent is TSESTree.ImportDeclaration | TSESTree.ImportExpression, but I think this is wrong.

Additional Info

No response

Versions

package version
@typescript-eslint/eslint-plugin 8.12.2
@typescript-eslint/parser 8.12.2
@typescript-eslint/rule-tester 8.12.2
@typescript-eslint/scope-manager 8.12.2
@typescript-eslint/typescript-estree 8.12.2
@typescript-eslint/type-utils 8.12.2
@typescript-eslint/utils 8.12.2
TypeScript 5.6.2
ESLint 9.3.0
node 22.4.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    ASTPRs and Issues about the AST structureaccepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy