
여러 타입을 만족하는 하나의 타입, 타입 합치기(Intersection Type, union/&)
·
기술/TypeScript
1. Intersection TypeIntersection Type(교차 타입)은 TypeScript에서 두 개 이상의 타입을 합치는 방법 중 하나이다. `& 연산자`를 사용하여 여러 타입을 하나로 합친다. 합쳐진 타입은 모든 타입의 특성을 가지게 된다. interface Car { brand: string; speed: number;}interface Electric { battery: number;}type ElectricCar = Car & Electric;const myCar: ElectricCar = { brand: 'Tesla', speed: 200, battery: 75,};//이렇게도 가능type PositionX = { x: number };type PositionY = { y..