Type Alias CamelCasedPropertiesDeep<Value, Options>

CamelCasedPropertiesDeep: Value extends Function
    ? Value
    : Value extends (infer U)[]
        ? CamelCasedPropertiesDeep<U, Options>[]
        : Value extends Set<infer U>
            ? Set<CamelCasedPropertiesDeep<U, Options>>
            : {
                [K in keyof Value as CamelCase<K, Options>]: CamelCasedPropertiesDeep<
                    Value[K],
                    Options,
                >
            }

Convert object properties to camel case recursively.

This can be useful when, for example, converting some API types from a different style.

Type Parameters

  • Value
  • Options extends CamelCaseOptions = { preserveConsecutiveUppercase: true }
  • CamelCasedProperties
  • CamelCase
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',
},
],
};