In the previous post I’ve explained what discriminated unions are in the TypeScript language. We’ll now look into a classic example of how this concept can be applied to a real-world scenario – building an interpreter.
In this post, we’re going to look into an interesting feature of the TypeScript language. It’s called discriminated unions and is also known as algebraic data types. The latter name comes from Functional Programming paradigm where such types are used very heavily.