export type ConditionalKeys = NonNullable< // Wrap in `NonNullable` to strip away the `undefined` type from the produced union. { // Map through all the keys of the given base type. [Key in keyof Base]: Base[Key] extends Condition // Pick only keys with types extending the given `Condition` type. ? // Retain this key since the condition passes. Key : // Discard this key since the condition fails. never // Convert the produced object into a union type of the keys which passed the conditional test. }[keyof Base] > export type ConditionalPick = Pick< Base, ConditionalKeys >