Conditional Types in TypeScript

These types allow you to make a decision about the type of a property at compile time. They are useful in constructing new utility types, like for example nullable:

/**
 * Exclude null and undefined from T
 */
type NonNullable<T> = T extends null | undefined ? never : T;