Type alias EndsWith<Value, Target>

EndsWith<Value, Target>: Value extends `${string}${Target}`
    ? true
    : false

EndsWith

Type Parameters

  • Value extends string

    The string to check

  • Target extends string

    The target to check

Desc

Check if a string ends with another string

Returns

A boolean

Example

type Value = 'foobar';
type Target = 'bar';
type Result = EndsWith<Value, Target>; // true

Example

type Value = 'foobar';
type Target = 'foo';
type Result = EndsWith<Value, Target>; // false