Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Bug: error TS2742 in eslint.config.mjs with "composite": true and pnpm #10893

Open
@andersk

Description

@andersk

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.

Issue Description

In a project configured with "composite": true and installed with pnpm, TypeScript flags error TS2742 in this minimal eslint.config.mjs.

// @ts-check
import tseslint from "typescript-eslint";
export default tseslint.config(tseslint.configs.recommended);

eslint.config.mjs:3:1 - error TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/@[email protected][email protected][email protected]/node_modules/@typescript-eslint/utils/ts-eslint'. This is likely not portable. A type annotation is necessary.

Full tsconfig.json:

{
  "compilerOptions": {
    "allowJs": true,
    "composite": true,
    "module": "nodenext",
    "noEmit": true,
    "strict": true
  }
}

The error is not shown without "composite": true, nor is it shown when using npm instead of pnpm.

Related:

Reproduction Repository Link

https://gist.github.com/andersk/44d8dd0d3c2508f758bf51e5cbf12c2f

Repro Steps

$ git clone https://gist.github.com/andersk/44d8dd0d3c2508f758bf51e5cbf12c2f test
$ cd test
$ pnpm i
Packages: +116
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 116, reused 116, downloaded 0, added 116, done

dependencies:
+ eslint 9.21.0
+ typescript 5.7.3
+ typescript-eslint 8.25.0

Done in 1.9s using pnpm v10.5.1

$ pnpm exec tsc
eslint.config.mjs:3:1 - error TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/@[email protected][email protected][email protected]/node_modules/@typescript-eslint/utils/ts-eslint'. This is likely not portable. A type annotation is necessary.

3 export default tseslint.config(tseslint.configs.recommended);
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error in eslint.config.mjs:3

Versions

package version
@typescript-eslint/eslint-plugin 8.25.0
@typescript-eslint/parser 8.25.0
@typescript-eslint/scope-manager 8.25.0
@typescript-eslint/typescript-estree 8.25.0
@typescript-eslint/type-utils 8.25.0
@typescript-eslint/utils 8.25.0
TypeScript 5.7.3
ESLint 9.21.0
node 22.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinggood first issueGood for newcomerspackage: typescript-eslintIssues related to the typescript-eslint package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions