export function enumToKeyValueArray<E extends Record<string, string | number>>(
enumObj: E
): KeyValueEntry<keyof E, E[keyof E]>[] {
return Object.entries(enumObj).map(([key, value]) => ({
value: key as keyof E,
label: value as E[keyof E],
}));
}
Last active
May 31, 2024 17:28
-
-
Save kouameYao/014636a122ca2558aa024bd5ab4b10a6 to your computer and use it in GitHub Desktop.
explore-more
interface MyParams {
canDownload?: boolean;
handleDownload?: () => void;
}
type RequireBothOrNone<T> = (T extends { paramA: infer A } ? A extends undefined
? {} : { paramB: string } : {})
& (T extends { paramB: infer B } ? (B extends undefined ? {} : { paramA: string }) : {});
type LinkParams = MyParams & RequireBothOrNone<MyParams>;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment