-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[prefer-readonly-parameter-types] False positive with React.PropsWithChlidren #4492
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
Comments
Heads up that we have our own playground at https://typescript-eslint.io/ |
I noticed it, but:
|
Looks like there is a bug in the playground which is breaking the rule - filed #4493. As for glitch - I don't have the option to open the terminal, so I can't run your repro. If I had to guess - it's likely one of the recent changes to the underlying tooling that caused this regression. |
Actually looking deeper.... I think this is expected behaviour. It might seem counter-intuitive, but technically without making it deeply readonly - it's valid for you to do like There's #4436 which adds an ignore list to the rule, which may be of interest if you want to ignore specific types and treat them as always readonly. |
Thank you for the explanation, it feels so obvious now that you figured it out :D I'll try to use the type allowlist as you suggested. Good Saturday! |
I have something that I believe is a false positive with
React.PropsWithChildren
. The following function doesn't break the rule:But the next one does:
And the next one too:
Repro
I have created a reproduction sandbox on Glitch: just open the terminal and run
npx eslint src/test.tsx
.Expected Result
I expect that Eslint shouldn't report an error
Actual Result
Eslint reports an error:
Additional Info
Versions
@typescript-eslint/eslint-plugin
5.10.1
@typescript-eslint/parser
5.10.1
TypeScript
4.5.5
ESLint
8.8.0
node
16.12.0
The text was updated successfully, but these errors were encountered: