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
686B

  1. import {DelimiterCase} from './delimiter-case';
  2. /**
  3. Convert a string literal to kebab-case.
  4. This can be useful when, for example, converting a camel-cased object property to a kebab-cased CSS class name or a command-line flag.
  5. @example
  6. ```
  7. import {KebabCase} from 'type-fest';
  8. // Simple
  9. const someVariable: KebabCase<'fooBar'> = 'foo-bar';
  10. // Advanced
  11. type KebabCasedProps<T> = {
  12. [K in keyof T as KebabCase<K>]: T[K]
  13. };
  14. interface CliOptions {
  15. dryRun: boolean;
  16. includeFile: string;
  17. foo: number;
  18. }
  19. const rawCliOptions: KebabCasedProps<CliOptions> = {
  20. 'dry-run': true,
  21. 'include-file': 'bar.js',
  22. foo: 123
  23. };
  24. ```
  25. */
  26. export type KebabCase<Value> = DelimiterCase<Value, '-'>;