TypeScript Types
Intersection types — combined requirements
An intersection requires a value to satisfy each constituent type. Combining object contracts may accumulate required properties, while incompatible property types can make a property impossible to supply. Intersections do not merge two runtime objects. Use an object-spread operation if you actually need to create a combined value, and check conflicts separately. Example output: "5". The example was designed for strict checking with an ES2022 target; type annotations do not add runtime validation.
Formal Syntax & Structure
typescript syntaxtypescript
type Combined = A & B;Working Example
Example Snippettypescript
type Located = { x: number } & { y: number };const point: Located = { x: 2, y: 3 };console.log(point.x + point.y);