Interface type check with Typescript
@lebyy▲ 0 net votes
Problem: This question is the direct analogon to Class type check in TypeScript I need to find out at runtime if a variable of type any implements an interface. Here's my code: interface A { member: string; } var a: any = { member: "foobar" }; if (a instanceof A)… Fix (from the top answer): You can achieve what you want without the instanceof keyword as you can write custom type guards now: interface A { member: string; } function instanceOfA(object: any): object is A { return 'member' in object; } var a: any Lots of Members If you need to check a lot of members to determine whether an object matches…