April 2018
Beginner
536 pages
13h 21m
English
When Anders Hejlsberg added intersection types to TypeScript for the first time, he defined them as follows:
The following example declares three interfaces named A, B, and C. Then it declares an object named abc, whose type is the intersection type of the interfaces A, B, and C. As a result, the abc object has properties named a, b, and c, but not d:
interface A { a: string } interface B { b: string } interface C { c: string } declare let abc: A & B & C; abc.a = "hello"; // OK abc.b = "hello"; // ...