import { type CamelCasedPropertiesDeep } from "https://deno.land/x/actionify@0.3.0/src/deps/types.ts";
Convert object properties to camel case recursively.
This can be useful when, for example, converting some API types from a different style.
Examples
Example 1
Example 1
import type {CamelCasedPropertiesDeep} from 'type-fest';
interface User {
UserId: number;
UserName: string;
}
interface UserWithFriends {
UserInfo: User;
UserFriends: User[];
}
const result: CamelCasedPropertiesDeep<UserWithFriends> = {
userInfo: {
userId: 1,
userName: 'Tom',
},
userFriends: [
{
userId: 2,
userName: 'Jerry',
},
{
userId: 3,
userName: 'Spike',
},
],
};
definition: Value extends Function ? Value : Value extends Array<infer U> ? Array<CamelCasedPropertiesDeep<U>> : Value extends Set<infer U> ? Set<CamelCasedPropertiesDeep<U>> : [K in keyof Valuein keyof CamelCase<K>]: CamelCasedPropertiesDeep<Value[K]>