Skip to content
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

ReadonlyDeep is inconsistent with typescript eslint's isTypeReadonly with regard to readonly sets and map #357

Closed
RebeccaStevens opened this issue Jan 29, 2022 · 0 comments · Fixed by #358

Comments

@RebeccaStevens
Copy link
Contributor

With regard to readonly sets and map, this library's ReadonlyDeep type is not consistent with the isTypeReadonly function from @typescript-eslint/type-utils that is used for eslint rules such as @typescript-eslint/prefer-readonly-parameter-types.

ReadonlyDeep converts Sets and Maps to ReadonlySets and ReadonlyMaps respectively. However, ReadonlySet and ReadonlyMap still have mutable methods. To make these types fully readonly and pass the isTypeReadonly function, the types need to be wrapped in Readonly, e.g. Readonly<ReadonlySet<T>>.

Note: ReadonlyArray doesn't need to be wrapped in Readonly as TypeScript just treats Readonly<ReadonlyArray<T>> the same as ReadonlyArray<T>. i.e. Both have mutable methods. As far as I know there is no way to easily make the methods on an array immutable. The isTypeReadonly function makes an exception for arrays having mutable methods.

RebeccaStevens added a commit to RebeccaStevens/type-fest that referenced this issue Jan 29, 2022
RebeccaStevens added a commit to RebeccaStevens/type-fest that referenced this issue Jan 29, 2022
RebeccaStevens added a commit to RebeccaStevens/type-fest that referenced this issue Jan 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant