Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

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

13,590 Aufrufe • vor 1 Jahr •via X (Twitter)

10 Kommentare

Profilbild von Georg Unterholzner
Georg Unterholznervor 1 Jahr

Very well explained, Cory!

Profilbild von lazy_coder
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?

Profilbild von Tanguy Krotoff
Tanguy Krotoffvor 1 Jahr

Fully-typed and fully-tested deepFreeze:

Profilbild von 𝕃𝕏𝔼
𝕃𝕏𝔼vor 1 Jahr

we need a 5th way

Profilbild von Cory House
Cory Housevor 1 Jahr

I’m likely forgetting at least two

Profilbild von aiiiden 💫💖
aiiiden 💫💖vor 1 Jahr

@ezdubs_bot english to japanese

Profilbild von Nitesh ₿⚡️
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.

Profilbild von Oliver
Olivervor 1 Jahr

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

Profilbild von Cory House
Cory Housevor 1 Jahr

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

Profilbild von Cory House
Cory Housevor 1 Jahr

Full course with a 20% discount:

Ähnliche Videos