Video wird geladen...
Video konnte nicht geladen werden
In TypeScript, there are at least 4 ways to implement immutability. Here's how I choose between them.
13,603 Aufrufe • vor 1 Jahr •via X (Twitter)
10 Kommentare

Georg Unterholznervor 1 Jahr
Very well explained, Cory!

lazy_codervor 1 Jahr
Question: At what point in the development cycle do you begin to worry about immutability? For solo or very small teams focused on deploying asap should this be a priority?

Tanguy Krotoffvor 1 Jahr
Fully-typed and fully-tested deepFreeze:

𝕃𝕏𝔼vor 1 Jahr
we need a 5th way

Cory Housevor 1 Jahr
I’m likely forgetting at least two

aiiiden 💫💖vor 1 Jahr
@ezdubs_bot english to japanese

Nitesh ₿⚡️vor 1 Jahr
Only in JavaScript, we declare something as const but then add an `as const` at the end of it to say, please remain immutable.

Olivervor 1 Jahr
So how would you choose between the typescript versions? Mainly when to use `as const` vs `readonly/ReadOnly`

Cory Housevor 1 Jahr
readonly is the only granular option. Otherwise I generally prefer “as const”

Cory Housevor 1 Jahr
Full course with a 20% discount:



