작성
·
193
3
이름은 분명히 union이니까 합집합 같은데 하는건 교집합같은 것(or연산자를 이용해서)을 하고 있고.. 뭐지 너무 헷갈리네해서 찾아봤는데요 참고 하실분들 참고하세요
타입스크립트 공홈에서 퍼왔습니다.
It might be confusing that a union of types appears to have the intersection of those types’ properties. This is not an accident - the name union comes from type theory. The union
number | string
is composed by taking the union of the values from each type. Notice that given two sets with corresponding facts about each set, only the intersection of those facts applies to the union of the sets themselves. For example, if we had a room of tall people wearing hats, and another room of Spanish speakers wearing hats, after combining those rooms, the only thing we know about every person is that they must be wearing a hat.