2 ms·
Immutability is also something you can model in the type system (not currently in Typescript, but it is possible in other languages). That said, immutability b
by svieira 10y ago
Immutability is also something you can model in the type system (not currently in Typescript, but it is possible in other languages).
That said, immutability by itself won't save you from passing the wrong shape of immutable object into a function, just as validating the shape of the argument passed and the argument expected against each other won't help if there are other assumptions being made by the code (such as that the object cannot be mutated). As one of the parent comments pointed out, types are proofs. Not everything can be proved to a compiler, but (assuming a bug-free compiler) everything which can be proved to a compiler does not need any additional tests. Things which cannot be proved to a compiler will need tests, of course.