Conditional types add logic to the type system. They distribute over unions when the checked type is a naked generic. Use `infer` to pull out parts of a type.
type IsString<T> = T extends string ? true : false;type IsString<T> = T extends string ? true : false;
type A = IsString<string>; // true
type B = IsString<number>; // false
type ElementType<T> = T extends (infer U)[] ? U : T;
type Num = ElementType<number[]>; // number
// Distributive behavior
type Nullable<T> = T | null;
type NonNullable<T> = T extends null | undefined ? never : T;
type Result = NonNullable<string | null>; // stringUnderstanding Conditional Types is fundamental to mastering TypeScript. Practice with the examples above and experiment with variations to solidify your knowledge.