main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 16 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
608 bytes
|
Line | |
---|
1 | import {CamelCase} from './camel-case';
|
---|
2 |
|
---|
3 | /**
|
---|
4 | Converts a string literal to pascal-case.
|
---|
5 |
|
---|
6 | @example
|
---|
7 | ```
|
---|
8 | import {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: CamelCasedProps<ModelProps> = {
|
---|
27 | DryRun: true,
|
---|
28 | FullFamilyName: 'bar.js',
|
---|
29 | Foo: 123
|
---|
30 | };
|
---|
31 | ```
|
---|
32 | */
|
---|
33 |
|
---|
34 | export type PascalCase<Value> = CamelCase<Value> extends string
|
---|
35 | ? Capitalize<CamelCase<Value>>
|
---|
36 | : CamelCase<Value>;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.