Skip to content

Bug: [prefer-readonly-parameter-types] Doesn't work on DeepReadonly from ts-essentials, utility-types, and type-fest #8932

@emily61268

Description

@emily61268

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.

Playground Link

https://typescript-eslint.io/play/#ts=5.4.3&fileType=.tsx&code=JYWwDg9gTgLgBAbzgEQKarAJVQQwCYQB2ANgJ5wC%2BcAZlBCHAOQwDOAtKiy6oTMDsRaMA3AChRqAB6RYNAK6EAxnyJwW9VGhAQAYguXAiAClFw1MUsU3ADRHFFIAuFOiy4CJUgB4AyhavINiqE9qQAdADC0KgAfAA0pnAhIKjOLDBQwIQA5gkAlM4AcjgpeL4aAOJ0cmAxiIlQqDByUIRqGgDyMAAWqFB6SsEmZmYIiSNJJalwAAZ4qNoA9AAkCMmoFDMJE2bqKR0ARgBWqMpp-ta2IQ5he6hVEDUA2usAutsjFIl5Yl9AA&eslintrc=N4KABGBEBOCuA2BTAzpAXGYBfEWg&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

export function someDemoFunction(
    styleDictionary: DeepReadonly<StyleDictionary.Core>,
    name: string,
): Named<SomeGroup> {
  return someOtherFunction(
      {
        name: `demo/${name}`,
        someObject: styleDictionary.someGroup[name],
      }
  );
}

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/prefer-readonly-parameter-types": [
        "error",  
        { ignoreInferredTypes: true },
    ],
  },
};

tsconfig

{
  "compilerOptions": {
    // ...
  }
}

Expected Result

There shouldn't be any eslint errors.

Actual Result

Returns the following error for styleDictionary: DeepReadonly<StyleDictionary.Core>.
34:3 error Parameter should be a read only type @typescript-eslint/prefer-readonly-parameter-types

Additional Info

Data types in StyleDictionary.Core: https://github.com/amzn/style-dictionary/blob/main/types/index.d.ts#L59
ts-essentials DeepReadonly: https://github.com/ts-essentials/ts-essentials/blob/master/lib/deep-readonly/index.ts
utility-types DeepReadonly: https://github.com/piotrwitek/utility-types/blob/master/src/mapped-types.ts#L407
type-fest ReadonlyDeep (recommended in this issue): https://github.com/sindresorhus/type-fest/blob/main/source/readonly-deep.d.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting responseIssues waiting for a reply from the OP or another partybugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions