source: trip-planner-front/node_modules/type-fest/ts41/kebab-case.d.ts@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 686 bytes
Line 
1import {DelimiterCase} from './delimiter-case';
2
3/**
4Convert a string literal to kebab-case.
5
6This can be useful when, for example, converting a camel-cased object property to a kebab-cased CSS class name or a command-line flag.
7
8@example
9```
10import {KebabCase} from 'type-fest';
11
12// Simple
13
14const someVariable: KebabCase<'fooBar'> = 'foo-bar';
15
16// Advanced
17
18type KebabCasedProps<T> = {
19 [K in keyof T as KebabCase<K>]: T[K]
20};
21
22interface CliOptions {
23 dryRun: boolean;
24 includeFile: string;
25 foo: number;
26}
27
28const rawCliOptions: KebabCasedProps<CliOptions> = {
29 'dry-run': true,
30 'include-file': 'bar.js',
31 foo: 123
32};
33```
34*/
35
36export type KebabCase<Value> = DelimiterCase<Value, '-'>;
Note: See TracBrowser for help on using the repository browser.