UNPKG

635 BTypeScriptView Raw
1import type {DelimiterCasedProperties} from './delimiter-cased-properties';
2
3/**
4Convert object properties to snake case but not recursively.
5
6This can be useful when, for example, converting some API types from a different style.
7
8@see SnakeCase
9@see SnakeCasedPropertiesDeep
10
11@example
12```
13import type {SnakeCasedProperties} from 'type-fest';
14
15interface User {
16 userId: number;
17 userName: string;
18}
19
20const result: SnakeCasedProperties<User> = {
21 user_id: 1,
22 user_name: 'Tom',
23};
24```
25
26@category Change case
27@category Template literal
28@category Object
29*/
30export type SnakeCasedProperties<Value> = DelimiterCasedProperties<Value, '_'>;