Type alias
Type aliases are used to give a new name to a type.
Simple example:
type Name = string;
type NameResolver = () => string;
type NameOrResolver = Name | NameResolver;
function getName(n: NameOrResolver): Name {
if (typeof n === 'string') {
return n;
} else {
return n();
}
}
In the above example, we use type to create type aliases. Type aliases are often used for union types.