Type aliases
Last updated
Last updated
Type aliases are used to give a new name to an existing type. Type aliases can name , , , , , and any other types that you’d otherwise have to write by hand. It's important to reinforce the point that aliasing doesn’t actually create a new type. Rather, it creates a name that references an already-existing type.
Let's pick up our previous example from section:
Let's create an alias Band
to refer to the object literal type:
Now the type Band
is shared across multiple objects.
Although aliasing a primitive is not terribly useful, it can be used as a form of documentation.