At first, our team found many such codes, because that is what we are used to in languages like ActionScript.
var arrayOfFoo : Array<Foo> = new Array<Foo>();
var someFoo : Foo = arrayOfFoo[0];
someFoo.someFooMethod();
This is great, but it can be simplified by relying more heavily on Typescript type inference:
//No need to declare the type ": Array<Foo>" here:
var arrayOfFoo = new Array<Foo>();
//Again, no need to declare that someFoo is a Foo
var someFoo = arrayOfFoo[0];
someFoo.someFooMethod();
Typescript is pretty good at type inference. If I omit the type on the left side of the assignments, the compiler still knows what type this object is, and still give a compilation error if I try to do something with a variable that type inferrred cannot do.
, . , , "" , , , , . , , .