Challenge 1: Build a Nested Conditional — Possible Solution ==================================================================== type Flatten = T extends (infer E)[] ? E : T extends Promise ? U : T; // --- Usage --- type A = Flatten; // string type B = Flatten>; // number type C = Flatten; // boolean (unchanged — neither array nor Promise) // A more thorough check with a helper that forces the compiler to display // the resolved type (useful while experimenting in an editor): type Check = T extends Expected ? (Expected extends T ? true : false) : false; type CheckA = Check; // true type CheckB = Check; // true type CheckC = Check; // true WHY THIS WORKS -------------- - The two conditional branches are checked in order, exactly like an if / else if / else chain: first "is T an array," then "is T a Promise," then falling through to the final else. - `T extends (infer E)[] ? E : ...` only matches when T is genuinely an array type — `infer E` captures whatever the element type turns out to be, without needing to hard-code it. - `T extends Promise ? U : ...` follows the same pattern for Promise — note this version only unwraps one level, unlike the self-recursive Awaited2 example from the chapter (that's exactly what Challenge 3 asks you to build). - Because array and Promise checks come before the final `T`, a type that is neither simply falls through unchanged.