1 | import type {CamelCaseOptions} from './camel-case';
|
2 | import type {PascalCase} from './pascal-case';
|
3 |
|
4 | /**
|
5 | Convert object properties to pascal case but not recursively.
|
6 |
|
7 | This can be useful when, for example, converting some API types from a different style.
|
8 |
|
9 | @see PascalCase
|
10 | @see PascalCasedPropertiesDeep
|
11 |
|
12 | @example
|
13 | ```
|
14 | import type {PascalCasedProperties} from 'type-fest';
|
15 |
|
16 | interface User {
|
17 | userId: number;
|
18 | userName: string;
|
19 | }
|
20 |
|
21 | const result: PascalCasedProperties<User> = {
|
22 | UserId: 1,
|
23 | UserName: 'Tom',
|
24 | };
|
25 | ```
|
26 |
|
27 | @category Change case
|
28 | @category Template literal
|
29 | @category Object
|
30 | */
|
31 | export type PascalCasedProperties<Value, Options extends CamelCaseOptions = {preserveConsecutiveUppercase: true}> = Value extends Function
|
32 | ? Value
|
33 | : Value extends Array<infer U>
|
34 | ? Value
|
35 | : {[K in keyof Value as PascalCase<K, Options>]: Value[K]};
|