Skip to content
Typetypesv0.14.4

StringEndsWith

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

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

BaseUnion

The union of strings to filter

BaseUnion extends string

EndingString

The string that valid members must end with

EndingString extends string