(no title)
adrice727 | 7 years ago
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...
No comments yet.