Composing types
Learn Composing types (Module 2 · TypeScript, Angular) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Union, intersection and literal types • A union type (A | B) says "one of these", like a form field that accepts either a number or text. An intersection type (A & B) says "all of these at once", merging shapes. A literal type is an exact value: 'asc' | 'desc' is a tidy alternative to magic strings.