type UnUnion = T extends S ? ([S] extends [T] ? T : never) : never; type NotUnion = UnUnion; /** * Literal requires that the given type is a literal value, and not a union of literals. */ export type Literal = OfType extends Value ? never // But the type must not extend the value (i.e. the two must not be equal) : NotUnion; // And the type must not be a union of literals /** Value must be a single string literal */ export type StringLiteral = Literal;