Aiding Typescript's type inference
If you want Typescript to determine the type of your variables correctly, do not do:
The type of myVar
will be interpreted to be any
instead of MyClass
. Typescript will not complain about it but you’ll not get any static type checking.
Instead, do:
or, if possible: