TYPESCRIPTChapter 3 · TS Advanced
Intersections and Assertions
Intersection Types (A & B) combine multiple types into one. Type Assertions (as Type) tell the compiler that a value has a specific type, bypassing regular type inference.
Worked example
How it reads
- Named & Aged combines properties of both interfaces
- as string forces the compiler to treat rawData as a string

Cloud tip: Use assertions sparingly: they tell the compiler 'trust me, I know what I am doing' and can hide real runtime errors if you are wrong.


