November 2018
Beginner
502 pages
10h 22m
English
In simple terms, a type alias creates a new name for a type. To define a type alias, we use the type keyword, followed by the alias name, followed by the type that we want to alias.
We'll explore this with the following example:
type GetTotal = (discount: number) => number;interface OrderDetail { product: Product; quantity: number; getTotal: GetTotal;}
Nothing changes with objects that implement this interface – it is purely a way we can structure our code. It arguably makes the code a little more readable.
Read now
Unlock full access