interface Tagged { tag: string; } interface Circle extends Tagged { tag: 'circle' } // ... Other implementations switch (myShape.tag) { case 'circle': { // Do circular things } // etc . . . }
1. https://www.typescriptlang.org/docs/handbook/advanced-types....
2. https://www.scala-lang.org/api/2.12.x/scala/annotation/switc...