Comment Comment by adrice727 It's a far cry from actual pattern matching, but you can always tag your types[1]: interface Tagged { tag: string; } interface Circle extends Tagged { tag: 'circle' } // ... Other implementations switch (myShape.tag) { case 'circle': { // Do circular things } // etc . . . } You'll occasionally even see this in Scala code, since the @switch annotation optimizes pattern-match statements[2].1. https://www.typescriptlang.org/docs/handbook/advanced-types....2. https://www.scala-lang.org/api/2.12.x/scala/annotation/switc... parent adrice727 8 years ago
1. https://www.typescriptlang.org/docs/handbook/advanced-types....
2. https://www.scala-lang.org/api/2.12.x/scala/annotation/switc...