Typescript – Aliases

Hi in this post we are going to talk about Aliases with Typescript, if you want to read the last post click here.
Aliases
Aliases can represent primitive types, the way to declare a Alias is:
type Name = string;
or
type Sushi = {
calories: number
salty: boolean
tasty: boolean
}
type Cake = {
calories: number
sweet: boolean
tasty: boolean
}
Is interesting because we can combine aliases like this:
type Food = {
calories: number
tasty: boolean
}
type Sushi = Food & {
salty: boolean
}
type Cake = Food & {
sweet: boolean
}
Aliases can represent tuples and interfaces can’t:
type MyData = [number, string];
By Cristina Rojas.