Skip to content

Bug: Cannot find module @typescript-eslint/parser or its corresponding type declarations in TS file #7486

Closed as not planned
@utakotoba

Description

@utakotoba

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

parser

Playground Link

No response

Repro Code

import tsParser from "@typescript-eslint/parser"

ESLint Config

No response

tsconfig

{
    "compilerOptions": {
        "target": "ESNext",
        "module": "ESNext",
        "moduleResolution": "Node",
        "resolveJsonModule": true,
        "esModuleInterop": true,
        "strict": true,
        "noEmit": true,
    },
    "exclude": [
        "**/node_modules",
        "**/dist",
    ],
}

Expected Result

In typescript .ts file

CleanShot 2023-08-16 at 18 32 39@2x

it should happen like this with no typescript error

Actual Result

I've try to import this parser in ESLint Flat config which I used .ts file, the typescript report an error on the parser packages' types declaration.

CleanShot 2023-08-16 at 18 31 06@2x

Additional Info

We can bring a fix by simply add the "types": "./dist/index.d.ts" to packages.json so that the TypesScript could find the declaration file in dist instead of trying to find it at ./index.d.ts leading to a error while there is not a ./index.d.ts but ./dist/index.d.ts.

CleanShot 2023-08-16 at 18 32 08@2x

I can bring up a PR if that's OK.

Versions

package version
@typescript-eslint/parser 6.4.0
TypeScript 5.1.6
node 20.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions