1 | import type {CamelCase, CamelCaseOptions} from './camel-case';
|
2 |
|
3 | /**
|
4 | Converts a string literal to pascal-case.
|
5 |
|
6 | @example
|
7 | ```
|
8 | import type {PascalCase} from 'type-fest';
|
9 |
|
10 | // Simple
|
11 |
|
12 | const someVariable: PascalCase<'foo-bar'> = 'FooBar';
|
13 |
|
14 | // Advanced
|
15 |
|
16 | type PascalCaseProps<T> = {
|
17 | [K in keyof T as PascalCase<K>]: T[K]
|
18 | };
|
19 |
|
20 | interface RawOptions {
|
21 | 'dry-run': boolean;
|
22 | 'full_family_name': string;
|
23 | foo: number;
|
24 | }
|
25 |
|
26 | const dbResult: CamelCasedProperties<ModelProps> = {
|
27 | DryRun: true,
|
28 | FullFamilyName: 'bar.js',
|
29 | Foo: 123
|
30 | };
|
31 | ```
|
32 |
|
33 | @category Change case
|
34 | @category Template literal
|
35 | */
|
36 | export type PascalCase<Value, Options extends CamelCaseOptions = {preserveConsecutiveUppercase: true}> = CamelCase<Value, Options> extends string
|
37 | ? Capitalize<CamelCase<Value, Options>>
|
38 | : CamelCase<Value, Options>;
|