forked from sindresorhus/type-fest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
snake-cased-properties-deep.d.ts
47 lines (39 loc) · 864 Bytes
/
snake-cased-properties-deep.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import type {DelimiterCasedPropertiesDeep} from './delimiter-cased-properties-deep';
/**
Convert object properties to snake case recursively.
This can be useful when, for example, converting some API types from a different style.
@see SnakeCase
@see SnakeCasedProperties
@example
```
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',
},
],
};
```
@category Change case
@category Template literal
@category Object
*/
export type SnakeCasedPropertiesDeep<Value> = DelimiterCasedPropertiesDeep<Value, '_'>;