forked from sindresorhus/type-fest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
camel-cased-properties.d.ts
36 lines (29 loc) · 798 Bytes
/
camel-cased-properties.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
import type {CamelCase, CamelCaseOptions} from './camel-case';
/**
Convert object properties to camel case but not recursively.
This can be useful when, for example, converting some API types from a different style.
@see CamelCasedPropertiesDeep
@see CamelCase
@example
```
import type {CamelCasedProperties} from 'type-fest';
interface User {
UserId: number;
UserName: string;
}
const result: CamelCasedProperties<User> = {
userId: 1,
userName: 'Tom',
};
```
@category Change case
@category Template literal
@category Object
*/
export type CamelCasedProperties<Value, Options extends CamelCaseOptions = {preserveConsecutiveUppercase: true}> = Value extends Function
? Value
: Value extends Array<infer U>
? Value
: {
[K in keyof Value as CamelCase<K, Options>]: Value[K];
};