type-fest
Version:
A collection of essential TypeScript types
47 lines (36 loc) • 1.16 kB
TypeScript
import type {DelimiterCasedProperties} from './delimiter-cased-properties.d.ts';
import type {WordsOptions} from './words.d.ts';
import type {KebabCase} from './kebab-case.d.ts'; // For `@link`
import type {KebabCasedPropertiesDeep} from './kebab-cased-properties-deep.d.ts'; // For `@link`
/**
Convert top-level object properties to kebab case.
This can be useful when, for example, converting some API types from a different style.
```
import type {KebabCasedProperties} from 'type-fest';
type User = {
userId: number;
userName: string;
};
const result: KebabCasedProperties<User> = {
'user-id': 1,
'user-name': 'Tom',
};
const splitOnNumbers: KebabCasedProperties<{line1: string}, {splitOnNumbers: true}> = {
'line-1': 'string',
};
const noSplitOnPunctuation: KebabCasedProperties<{'foo::bar': string}, {splitOnPunctuation: false}> = {
'foo::bar': 'string',
};
```
*/
export type KebabCasedProperties<
Value,
Options extends WordsOptions = {},
> = DelimiterCasedProperties<Value, '-', Options>;
export {};