Types vs Values

Most things in TypeScript are either types or values, existing in separate namespaces. You can even have a type and a variable with the same name, and TypeScript knows how to resolve them based on the usage context. This is called contextual term resolution, which is the foundation of the companion pattern.

Types are merely a hint to the compiler and will disappear at run time, only variables will be passed onto the runtime. Take Class, for example, which defines a type and the constructor function (the value) with the same name.

Literal values as types

TypeScript supports literal values as types. e.g., type Pet = 'dog' | 'cat'.