Home > types > DelimiterCase
Convert a string literal to a custom string delimiter casing.
This can be useful when, for example, converting a camel-cased object property to an oddly cased one.
Signature:
export declare type DelimiterCase<Value, Delimiter extends string> = Value extends string
? StringArrayToDelimiterCase<
SplitIncludingDelimiters<Value, WordSeparators | UpperCaseCharacters>,
true,
WordSeparators,
UpperCaseCharacters,
Delimiter
>
: Value;
``` import {DelimiterCase} from ‘type-fest’;
// Simple
const someVariable: DelimiterCase<‘fooBar’, ‘#’> = ‘foo#bar’;
// Advanced
type OddlyCasedProperties
interface SomeOptions { dryRun: boolean; includeFile: string; foo: number; }
const rawCliOptions: OddlyCasedProperties
Template Literals