platform-bible-utils
    Preparing search index...

    Type Alias KebabCase<T>

    KebabCase: T extends `${infer First}${infer Rest}`
        ? `${First extends Lowercase<First> ? First : `-${Lowercase<First>}`}${KebabCase<
            Rest,
        >}`
        : T

    Converts a string type from camelCase to kebab-case. Note this simply inserts hyphens before uppercase letters and converts them to lowercase. It does not handle special cases like acronyms or symbols. It can result in multiple hyphens in a row, leading hyphens, or trailing hyphens.

    By using this as the type for a string parameter or string property, you can enforce (somewhat) at compile time that the string is in kebab-case format assuming it is provided as a string literal.

    Type Parameters

    • T extends string
    type Kebab1 = KebabCase<'backgroundColor'>; // 'background-color'
    type Kebab2 = KebabCase<'HTMLParser'>; // '-h-t-m-l-parser'
    type Kebab3 = KebabCase<'simpletest'>; // 'simpletest'
    type Kebab4 = KebabCase<'My$Value'>; // '-my$-value'