正在加载视频...

视频加载失败

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

13,590 次观看 • 1 年前 •via X (Twitter)

10 条评论

Georg Unterholzner 的头像
Georg Unterholzner1 年前

Very well explained, Cory!

lazy_coder 的头像
lazy_coder1 年前

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 的头像
Tanguy Krotoff1 年前

Fully-typed and fully-tested deepFreeze:

𝕃𝕏𝔼 的头像
𝕃𝕏𝔼1 年前

we need a 5th way

Cory House 的头像
Cory House1 年前

I’m likely forgetting at least two

aiiiden 💫💖 的头像
aiiiden 💫💖1 年前

@ezdubs_bot english to japanese

Nitesh ₿⚡️ 的头像
Nitesh ₿⚡️1 年前

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 的头像
Oliver1 年前

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

Cory House 的头像
Cory House1 年前

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

Cory House 的头像
Cory House1 年前

Full course with a 20% discount:

相关视频