Skip to content

Instantly share code, notes, and snippets.

@MohammedEssehemy
Last active April 2, 2022 11:37
Show Gist options
  • Save MohammedEssehemy/65d327bb98ee5f0c3abcd359368a444f to your computer and use it in GitHub Desktop.
Save MohammedEssehemy/65d327bb98ee5f0c3abcd359368a444f to your computer and use it in GitHub Desktop.
typescript utils
export type ClassType<T> = new () => T;
type PrimitiveType = string | number | boolean | null | undefined | never | Function;
export type ConvertDateToString<T> =
T extends Date ? string :
T extends PrimitiveType ? T :
T extends Array<infer U> ? Array<ConvertDateToString<U>> :
{ [K in keyof T]: ConvertDateToString<T[K]> };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment