8c804dc525f23a167b64ee5735865b126fb8f74e34a0f76ee80ce6b40be6ce844b7ebf1b3a2e2e15514237bb8348f74f5c99a59b186295e6b272a3dfb86ee7 608 B

123456789101112131415161718192021222324252627282930313233343536
  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>;