Skip to content

Bug: [@typescript-eslint/prefer-readonly-parameter-types] gives error "Cannot read properties of undefined (reading 'checkFlags')" #11289

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
stephen-carter-at-sf opened this issue Jun 9, 2025 · 1 comment
Labels
bug Something isn't working external This issue is with another package, not typescript-eslint itself package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look

Comments

@stephen-carter-at-sf
Copy link

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

When I have a dependency on
"@types/jest": "^29.5.14",
then I get the following error:


TypeError: Cannot read properties of undefined (reading 'checkFlags')
Occurred while linting /Users/stephen.carter/temp/typescript_eslint_bug/test/dummy.test.ts:5
Rule: "@typescript-eslint/prefer-readonly-parameter-types"
    at isTransientSymbolLinksFlagSet (/Users/stephen.carter/temp/typescript_eslint_bug/node_modules/ts-api-utils/lib/index.cjs:143:26)
    at isInConstContext (/Users/stephen.carter/temp/typescript_eslint_bug/node_modules/ts-api-utils/lib/index.cjs:994:16)
    at /Users/stephen.carter/temp/typescript_eslint_bug/node_modules/ts-api-utils/lib/index.cjs:1088:464
    at Array.some (<anonymous>)
    at symbolHasReadonlyDeclaration (/Users/stephen.carter/temp/typescript_eslint_bug/node_modules/ts-api-utils/lib/index.cjs:1087:145)
    at /Users/stephen.carter/temp/typescript_eslint_bug/node_modules/ts-api-utils/lib/index.cjs:1172:5
    at Array.some (<anonymous>)
    at isReadonlyPropertyIntersection (/Users/stephen.carter/temp/typescript_eslint_bug/node_modules/ts-api-utils/lib/index.cjs:1154:23)
    at Object.isPropertyReadonlyInType (/Users/stephen.carter/temp/typescript_eslint_bug/node_modules/ts-api-utils/lib/index.cjs:1059:41)
    at isTypeReadonlyObject (/Users/stephen.carter/temp/typescript_eslint_bug/node_modules/@typescript-eslint/type-utils/dist/isTypeReadonly.js:138:25)

If I remove this dependency then I don't get the error.

Specifically in my jest test file it doesn't seem to like parameters in my describe calls.

I'm not sure if the @typescript-eslint/prefer-readonly-parameter-types rule has a bug or there is a conflict or what. But it took me forever to reduce my project down to this super small reproduction steps.

Reproduction Repository Link

https://github.com/stephen-carter-at-sf/typescript_eslint_bug

Repro Steps

  1. clone the repo
  2. npm install
  3. npx eslint test/dummy.test.ts

Versions

"@types/jest": "^29.5.14",
"jest": "^29.7.0",
"@eslint/js": "^9.28.0",
"eslint": "^9.28.0",
"typescript": "^5.8.3",
"typescript-eslint": "^8.33.1"
@stephen-carter-at-sf stephen-carter-at-sf added bug Something isn't working triage Waiting for team members to take a look labels Jun 9, 2025
@kirkwaiblinger
Copy link
Member

kirkwaiblinger commented Jun 9, 2025

Hi @stephen-carter-at-sf!

I've cloned this down and I can repro it... Not quite sure what the issue is, but I'm wondering whether this is possibly a bug in ts-api-utils. @JoshuaKGoldberg.

This was a tricky one but I was able to get a playground repro:

Code

declare const fooFactory: <T>(x: readonly T[]) => (f: (x: T) => void) => void;

fooFactory([{ abc: 42 }])((x) => { });
//                         ^ inspecting this parameter causes the crash

Eslint config

{
  "rules": {
    "@typescript-eslint/prefer-readonly-parameter-types": "warn"
  }
}

TypeScript config

{
  "compilerOptions": {
    "strictNullChecks": true
  }
}
package version
@typescript-eslint/eslint-plugin 8.34.0
@typescript-eslint/parser 8.34.0
TypeScript 5.4.5
ESLint 9.26.0
node web

@bradzacher bradzacher added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin external This issue is with another package, not typescript-eslint itself labels Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working external This issue is with another package, not typescript-eslint itself package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look
Projects
None yet
Development

No branches or pull requests

3 participants