import { type SnakeCasedPropertiesDeep } from "https://dotland.deno.dev/x/scaffold@0.3.0/src/deps/types.ts";
Convert object properties to snake case recursively.
This can be useful when, for example, converting some API types from a different style.
Examples
Example 1
Example 1
import type {SnakeCasedPropertiesDeep} from 'type-fest';
interface User {
userId: number;
userName: string;
}
interface UserWithFriends {
userInfo: User;
userFriends: User[];
}
const result: SnakeCasedPropertiesDeep<UserWithFriends> = {
user_info: {
user_id: 1,
user_name: 'Tom',
},
user_friends: [
{
user_id: 2,
user_name: 'Jerry',
},
{
user_id: 3,
user_name: 'Spike',
},
],
};
definition: DelimiterCasedPropertiesDeep<Value, "_">