Skip to content

Instantly share code, notes, and snippets.

@jmaicaaan
Last active August 17, 2022 15:07
Show Gist options
  • Select an option

  • Save jmaicaaan/75bae6b6315e4c1c3a45680ab59f5b23 to your computer and use it in GitHub Desktop.

Select an option

Save jmaicaaan/75bae6b6315e4c1c3a45680ab59f5b23 to your computer and use it in GitHub Desktop.
export type Camelize<GenericObject> = {
[ObjectProperty in keyof GenericObject as CamelizeString<ObjectProperty & string>]:
GenericObject[ObjectProperty] extends Array<infer ArrayItem>
? ArrayItem extends Record<string, unknown>
? Array<Camelize<ArrayItem>>
: GenericObject[ObjectProperty]
: GenericObject[ObjectProperty] extends Record<string, unknown>
? Camelize<GenericObject[ObjectProperty]>
: GenericObject[ObjectProperty];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment