|
|
|
|
|
by ItsHarper
204 days ago
|
|
That's opting into immutability, the point of the experiment is having it by default. Plus, that's just the type system preventing you from adding a property. It won't stop you from trying to change the `immutable` field. I'm genuinely curious, was this AI generated, or just a lack of understanding? |
|
You can also use "as const" to get the same behavior without any runtime calls:
But yes, OP wasn't referring to the article, they were just pointing out the narrower fact that Typescript does in fact have compile-time errors for mutating Object.freeze's return values.