8000 Bug: error TS2742 in eslint.config.mjs with `"composite": true` and pnpm · Issue #10893 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

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

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

Open
4 tasks done
andersk opened this issue Feb 27, 2025 · 4 comments
Open
4 tasks done

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

andersk opened this issue Feb 27, 2025 · 4 comments
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working good first issue Good for newcomers package: typescript-eslint Issues related to the typescript-eslint package

Comments

@andersk
Copy link
Contributor
andersk commented Feb 27, 2025

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/@typescript-eslint+utils@8.25.0_eslint@9.21.0_typescript@5.7.3/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/@typescript-eslint+utils@8.25.0_eslint@9.21.0_typescript@5.7.3/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
@andersk andersk added bug Something isn't working triage Waiting for team members to take a look labels Feb 27, 2025
@bradzacher
Copy link
Member

This is very similar to an issue that eslint upstream also had. Pnpm's linking installs plays a bit funky with typescript so it needs the package to declare some additional type exports for it to work.

@bradzacher bradzacher added good first issue Good for newcomers accepting prs Go ahead, send a pull request that resolves this issue package: typescript-eslint Issues related to the typescript-eslint package and removed triage Waiting for team members to take a look labels Feb 27, 2025
@fdendorfer
Copy link

I had the same error, but using a slightly different setup without tseslint.config(). I solved it by adding "eslint.config.mjs" to the exclude array in my tsconfig.json.

@ntnyq
Copy link
Contributor
ntnyq commented Mar 13, 2025

Upstream related issue:

eslint/eslint#19421

ESLint recommended workaround:
https://eslint.org/docs/latest/use/getting-started#manual-set-up

@fdendorfer
Copy link

Thanks for the hint @ntnyq

I can confirm this also works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working good first issue Good for newcomers package: typescript-eslint Issues related to the typescript-eslint package
Projects
None yet
Development

No branches or pull requests

4 participants
0