UNPKG

790 BTypeScriptView Raw
1import type {CamelCase, CamelCaseOptions} from './camel-case';
2
3/**
4Converts a string literal to pascal-case.
5
6@example
7```
8import type {PascalCase} from 'type-fest';
9
10// Simple
11
12const someVariable: PascalCase<'foo-bar'> = 'FooBar';
13
14// Advanced
15
16type PascalCaseProps<T> = {
17 [K in keyof T as PascalCase<K>]: T[K]
18};
19
20interface RawOptions {
21 'dry-run': boolean;
22 'full_family_name': string;
23 foo: number;
24}
25
26const 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*/
36export type PascalCase<Value, Options extends CamelCaseOptions = {preserveConsecutiveUppercase: true}> = CamelCase<Value, Options> extends string
37 ? Capitalize<CamelCase<Value, Options>>
38 : CamelCase<Value, Options>;