In TypeScript, there are at least 4 ways to implement immutability.
@housecor166K followers
13,603 views
10 Comments
Comments from the original post on X (Twitter)

@georg_dev
Very well explained, Cory!
2 likes

@real_lazy_coder
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?
2 likes

@tkrotoff
Fully-typed and fully-tested deepFreeze:
1 like

@lxe
we need a 5th way

@housecor
I’m likely forgetting at least two
1 like

@aiiiden0
@ezdubs_bot english to japanese

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

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

@housecor
readonly is the only granular option. Otherwise I generally prefer “as const”
2 likes

@housecor
Full course with a 20% discount:
