In ActionScript, it is possible to check the type at run-time using the is operator:
var mySprite:Sprite = new Sprite();
trace(mySprite is Sprite); // true
trace(mySprite is DisplayObject);// true
trace(mySprite is IEventDispatcher); // true
Is it possible to detect if a variable (extends or) is a certain class or interface with TypeScript?
I couldn't find anything about it in the language specs. It should be there when working with classes/interfaces.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…