DeepReadonly Object Typescript

As of TypeScript 2.8, this is now possible and actually an example in the PR for Conditional Types: https://github.com/Microsoft/TypeScript/pull/21316 Also see the notes on type inference for Conditional Types: https://github.com/Microsoft/TypeScript/pull/21496 I modified the example slightly to use the type inference for the readonly array value type because I find (infer R)[] clearer than Array<T[number]> but …

Read more

Why is this class mutable? [duplicate]

An arbitrary instance of Test isn’t guaranteed to be immutable, although direct instances of Test are. But consider this subclass: public class MutableTest extends Test { private int mutable; public MutableTest(String url) { super(url); } @Override public String getUrl() { return super.getUrl() + mutable++; } } Then you can write something like this: Test instance …

Read more