sindresorhus / type-fest

A collection of essential TypeScript types
Creative Commons Zero v1.0 Universal
14k stars 531 forks source link

Rename `ReadonlyDeep` to `Immutable` #480

Open RebeccaStevens opened 1 year ago

RebeccaStevens commented 1 year ago

The ReadonlyDeep type does more than just make types readonly, it fully makes them immutable.

There's been a bit of discussion over at typescript-eslint about "Readonly" vs "Immutable". This is in regard to eslint rules such as prefer-readonly-parameter-types. I've made a library that can calculate type immutability (is-immutable-type) in a way consistent with this and this library will be used in the next release of eslint-plugin-functional. It would be nice if this utility type was also consistent with these definitions.

Other issues of note: #396

Upvote & Fund

Fund with Polar

skarab42 commented 1 year ago

I think we need both types.

e-oz commented 1 year ago

ReadonlyDeep: The data is deeply immutable but methods are not.

Disagree. Readonly means readonly, even for methods.

There is "Readonly" built-in type in TS, so name ReadonlyDeep is quite intuitive when you need "Readonly" but not shallow.