by DexesTTP · 2y ago · 0 comments
type A = { value: number; }
function test(a: A) { a.value = 3; }
function main() {
const a: Readonly<A> = { value: 1 };
// a.value = 2; <= this errors out
test(a); // this doesn't error out
console.log(a); // shows 3
}Normally typescript does not just allow implicit removal of a container type.
Like, you can't pass Array<A> to a function that just takes A.