import type {ConditionalKeys} from 'type-fest';
interface Example {
a: string;
b: string | number;
c?: string;
d: {};
}
type StringKeysOnly = ConditionalKeys<Example, string>;
//=> 'a'
To support partial types, make sure your Condition is a union of undefined (for example, string | undefined) as demonstrated below.
Extract the keys from a type where the value type of the key extends the given
Condition.Internally this is used for the
ConditionalPickandConditionalExcepttypes.