If you want Typescript to determine the type of your variables correctly, do not do:

var myVar;
// Initialization code
myVar = new MyClass();

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:

var myVar : MyClass;
myVal = new MyClass();

or, if possible:

var myVar = new MyClass();