1.

What are intersection types?

Answer»

Intersection types let you combine the members of TWO or more types by using the ‘&’ operator. This allows you to combine existing types to get a SINGLE type with all the features you need.

The following example creates a NEW type Supervisor that has the members of types Employee and Manager.

interface Employee {WORK: () => string;}interface Manager {manage: () => string;}type Supervisor = Employee & Manager;// john can both work and managelet john: Supervisor;


Discussion

No Comment Found