Naming of TypeScript's union and intersection types

后端 未结 6 1092
忘掉有多难
忘掉有多难 2020-12-04 12:25

I can\'t understand the logic behind the terms union types and intersection types in TypeScript.

Pragmatically, if the properties of different type

6条回答
  •  天命终不由人
    2020-12-04 12:48

    The confusion here probably stems from how we imagine the sets, namely, thinking of the intersection/union as involving the members of types as opposed to the types themselves. I put together a graphic that hopefully clarifies the concept:

提交回复
热议问题