July 2017
Intermediate to advanced
300 pages
5h 43m
English
Interesting so far, isn't it? What would you say then to it: in TypeScript, we can refer to multiple types at once. For example, we have two interfaces Anakin and Padmé and need a new type (Luke) that inherits from both of them. We can achieve it as easily as this:
interface Anakin {
useLightSaber: () => void;
useForce: () => void;
}
interface Padmé {
leaderSkills: string[];
useGun: () => void;
}
type Luke = Anakin & Padmé;
Besides, we can do the intersection without explicitly declaring the type:
function joinRebelion( luke: Anakin & Padmé ){
}
We can also define a union type that allows any type of a group. You know the jQuery library, right? The function jQuery accepts for a selector parameter a number ...
Read now
Unlock full access