Type alias StartsWith<Value, Target>

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

StartsWith

Type Parameters

  • Value extends string

    The string to check

  • Target extends string

    The target to check

Desc

Check if a string starts with another string

Returns

A boolean

Example

type Value = 'foobar';
type Target = 'foo';
type Result = StartsWith<Value, Target>; // true

Example

type Value = 'foobar';
type Target = 'bar';
type Result = StartsWith<Value, Target>; // false