import { camelCase, isArray, isObject, mapKeys, mapValues } from 'lodash' type ObjType = Record | unknown[] | unknown export function deepCamelCaseKeys(obj: T): T { if (isArray(obj)) { return obj.map(deepCamelCaseKeys) as T } else if (isObject(obj)) { return mapValues( // @ts-ignore This mutates the object, but we don't care about the type here mapKeys(obj, (_value: string, key: string) => camelCase(key)), deepCamelCaseKeys ) as T } return obj }