You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
608B

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