-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
[prefer-readonly-type] doesn't catch mutable maps and sets #151
Comments
This seems like it could be a duplicate of #25, but even with checkImplicit true those constructor calls aren't flagged. 🤔 |
Readonly sets and maps are already supposed to supported. Set test: https://github.com/jonaskello/eslint-plugin-functional/blob/master/tests/rules/prefer-readonly-type.test.ts#L395-L409 I'll need to look more into this at a later date. |
No one else has reported this issue and its been open for quite a while now. I'm going to close this an assume everything is ok. |
I can guess why nobody else has reported the issue: arrays are omnipresent and so the (negative) consequences of them being mutable are most commonly encountered and highest priority to guard against. Sets and maps are comparatively less common and (speculating) when they are used their scope is much less than arrays (which get sprayed everywhere). Nevertheless, TypeScript does provide I won't create a new issue because it would just be identical to this one. I'll see if I can find some time to raise a PR. |
The |
Oh, I just noticed Thanks @RebeccaStevens |
Examples:
And with explicit readonly type annotation:
ReadonlySet
andReadonlyMap
are built-in TypeScript types, but they don't enjoy special syntax support like arrays do (you can't sayreadonly Set<string>
, you must sayReadonlySet<string>
). For this reason I suspect this issue is a cousin to #150 and #51.The text was updated successfully, but these errors were encountered: