UNPKG

880 BTypeScriptView Raw
1import type {DelimiterCasedPropertiesDeep} from './delimiter-cased-properties-deep';
2
3/**
4Convert object properties to kebab case recursively.
5
6This can be useful when, for example, converting some API types from a different style.
7
8@see KebabCase
9@see KebabCasedProperties
10
11@example
12```
13import type [KebabCasedPropertiesDeep] from 'type-fest';
14
15interface User {
16 userId: number;
17 userName: string;
18}
19
20interface UserWithFriends {
21 userInfo: User;
22 userFriends: User[];
23}
24
25const result: KebabCasedPropertiesDeep<UserWithFriends> = {
26 'user-info': {
27 'user-id': 1,
28 'user-name': 'Tom',
29 },
30 'user-friends': [
31 {
32 'user-id': 2,
33 'user-name': 'Jerry',
34 },
35 {
36 'user-id': 3,
37 'user-name': 'Spike',
38 },
39 ],
40};
41```
42
43@category Change case
44@category Template literal
45@category Object
46*/
47export type KebabCasedPropertiesDeep<Value> = DelimiterCasedPropertiesDeep<Value, '-'>;