Monday, May 22, 2017

Cast an any to another type in TypeScript.

This has this example:

var myObject: TypeA;
var otherObject: any;
myObject = <TypeA> otherObject;

 
 

...and this one too:

var myObject: TypeA;
var otherObject: any;
myObject = otherObject as TypeA;

 
 

It seems to me that you probably want to use let instead of var and you probably way to have something in the any before you assign it. :P

No comments:

Post a Comment