Kotlin Union type or its simulation.

TypeScript makes extensive use of the Union type, and Kotlin appears to be able to do so in a version 2.4 with help of Rich Errors feature.