Literals are types that refer to specific strings and numbers. They can be combined into unions to create types that only allow for a selection of strings or numbers. This can be useful for restricting propertys to specific values, such as fontWeight
only accepting bold
, bolder
, etc.
There are string literals and numeric literals
type alignment = 'left' | 'middle' | 'right' type fib = 1 | 2 | 3 | 5 | 8