Skip to content
Typetypesv0.14.4

StringStartsWith

Filters string union types to only include those that start with a specific string

type StringStartsWith<
    BaseUnion extends string,
    StartingString extends string
> = BaseUnion extends `${StartingString}${string}`
    ? BaseUnion
    : never;

BaseUnion

The union of strings to filter

BaseUnion extends string

StartingString

The string that valid members must start with

StartingString extends string