A conditional type has the form `T extends U ? X : Y`, evaluated at the type level rather than at runtime.
ts type IsString<T> = T extends string ? true : false; type A = IsString<"hi">; // true type B = IsString<42>; // false type Flatten<T> = T extends (infer U)[] ? U : T; type C = Flatten<number[]>; // number type D = Flatten<string>; // string
`infer` introduces a new type variable inside the `extends` clause, letting you extract a piece of a type — `Flatten` pulls the element type out of an array, otherwise returns the type unchanged. Conditional types combined with `infer` power many of the utility types you use daily, like `ReturnType<T>` and `Parameters<T>`.