Loading video...

Video Failed to Load

Go Home

In TypeScript, there are at least 4 ways to implement immutability. Here's how I choose between them.

13,590 views • 1 year ago •via X (Twitter)

10 Comments

Georg Unterholzner's profile picture
Georg Unterholzner1 year ago

Very well explained, Cory!

lazy_coder's profile picture
lazy_coder1 year ago

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 Krotoff's profile picture
Tanguy Krotoff1 year ago

Fully-typed and fully-tested deepFreeze:

𝕃𝕏𝔼's profile picture
𝕃𝕏𝔼1 year ago

we need a 5th way

Cory House's profile picture
Cory House1 year ago

I’m likely forgetting at least two

aiiiden 💫💖's profile picture
aiiiden 💫💖1 year ago

@ezdubs_bot english to japanese

Nitesh ₿⚡️'s profile picture
Nitesh ₿⚡️1 year ago

Only in JavaScript, we declare something as const but then add an `as const` at the end of it to say, please remain immutable.

Oliver's profile picture
Oliver1 year ago

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

Cory House's profile picture
Cory House1 year ago

readonly is the only granular option. Otherwise I generally prefer “as const”

Cory House's profile picture
Cory House1 year ago

Full course with a 20% discount:

Related Videos