Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[prefer-readonly-parameter-types] inferred types from third party code make rule painful #2079

Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulegood first issueGood for newcomerslocked 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
@osdiab

Description

@osdiab

i like the concept of the checker, but it's a pain in the butt in practice if you use third party libraries with typings and hope to use typescript's inference engine, because it errors like crazy.

Repro
Install one of many popular libraries:

yarn add -D ava# or maybeyarn add io-ts
{"rules": {"@typescript-eslint/prefer-readonly-parameter-types": ["error"]  }}
// ava - t is not deeply readonly so it errors// ava's typings don't make this deeply readonly, so it's clear why this would failimporttestfrom"ava";test('Stub',(t)=>{t.is(1,1);});

or maybe

importtfromio-ts;// this fails as well - which is extra frustrating since that library even goes to lengths to make things readonly in its typings!// though I'm guessing it's triggering on the `unknown` values, which isnt feasible to eliminate for this library// https://github.com/gcanti/io-ts/blob/73d92a08c42dca3d874927d92c8e9ad30d0a11f5/src/index.ts#L28constparseValidationError=(error:t.ValidationError)=>{returnerror;}

Expected Result

  • that there be configuration options to make the rule more usable for third party typings, some kind of escape hatch that doesn't involve adding an eslint ignore comment over and over again all over my app for inferred types - for example theunknown values inio-ts are essential to its usage, and I trust it, so I'm OK with letting anything fromio-ts slide
  • also that there be a little more detail on what exactly was not readonly, since it's sometimes not straightforward to tell from complex types especially from third party libraries what might be wrong, so it's hard for me to make ticket for third parties when it happens

Actual Result
Errors that I can't fix since it's not my typings, besides just ignoring the rule or turning it off

Versions

packageversion
@typescript-eslint/eslint-plugin2.29.0
@typescript-eslint/parser2.29.0
TypeScript3.9.3
ESLint6.8.0
node12.16.3
npm6.14.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulegood first issueGood for newcomerslocked 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


      [8]ページ先頭

      ©2009-2025 Movatter.jp