-
-
Notifications
You must be signed in to change notification settings - Fork 679
Expand file tree
/
Copy pathsnake-cased-properties.d.ts
More file actions
46 lines (36 loc) · 1.18 KB
/
snake-cased-properties.d.ts
File metadata and controls
46 lines (36 loc) · 1.18 KB
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
import type {_DefaultDelimiterCaseOptions} from './delimiter-case.d.ts';
import type {DelimiterCasedProperties} from './delimiter-cased-properties.d.ts';
import type {ApplyDefaultOptions} from './internal/index.d.ts';
import type {WordsOptions} from './words.d.ts';
/**
Convert object properties to snake case but not recursively.
This can be useful when, for example, converting some API types from a different style.
@see {@link SnakeCase}
@see {@link SnakeCasedPropertiesDeep}
@example
```
import type {SnakeCasedProperties} from 'type-fest';
type User = {
userId: number;
userName: string;
};
const result: SnakeCasedProperties<User> = {
user_id: 1,
user_name: 'Tom',
};
const splitOnNumbers: SnakeCasedProperties<{line1: string}, {splitOnNumbers: true}> = {
'line_1': 'string',
};
const splitOnPunctuation: SnakeCasedProperties<{'foo::bar': string}, {splitOnPunctuation: true}> = {
'foo_bar': 'string',
};
```
@category Change case
@category Template literal
@category Object
*/
export type SnakeCasedProperties<
Value,
Options extends WordsOptions = {},
> = DelimiterCasedProperties<Value, '_', ApplyDefaultOptions<WordsOptions, _DefaultDelimiterCaseOptions, Options>>;
export {};