Hacker News new | ask | show | jobs
by bioemerl 1096 days ago
Instance of doesn't work sometimes and you have to write explicit property checks. I forget the details because I'm by no means a typescript expert, but I remember being very frustrated by the fact I couldn't just use instance of.
2 comments

It doesn't work when objects cross global scope boundary (e.g. you get an object from a frame), there's no fixing that, by design the namespaces are different and unrelated.
instanceof only works with JavaScript classes. Not on regular objects that just structurally conform to a type or interface.