Restricting generic types to one of several classes in Typescript
I banged my head on this for a few hours, but the solution seems obvious in retrospect. First I present the solution, then I compare it to prior approaches. (Tested in Typescript 2.6.2.) // WORKING SOLUTION: union of types with type checks class MustBeThis { method1() { } } class OrThis { method2() { } … Read more