Type Alias IsString<T, $O>

IsString<T, $O>: $SpecialType<T, $MergeOptions<$O, {
    $else: IsString.$<T, $O>;
    $then: $ResolveBranch<T, $O, [$Else]>;
}>>

🎭 predicate

Validate if T is string or string literals.

Type Parameters

type R = IsString<string> // true
type R = IsString<'a'> // true

type R = IsString<never> // false
type R = IsString<unknown> // false
type R = IsString<string | boolean> // boolean

🔢 customize

Filter to ensure T is string or string literals, otherwise returns never.

type R = IsString<string, { selection: 'filter' }> // string
type R = IsString<'a', { selection: 'filter' }> // 'a'

type R = IsString<never, { selection: 'filter' }> // never
type R = IsString<unknown, { selection: 'filter' }> // never
type R = IsString<string | boolean, { selection: 'filter' }> // string

🔢 customize:

Disable distribution of union types.

type R = IsString<string | 1> // boolean
type R = IsString<string | 1, { distributive: false }> // false

🔢 customize

Use unique branch identifiers to allow precise processing of the result.

type R = IsString<string, $IsString.$Branch> // $Then
type R = IsString<bigint, $IsString.$Branch> // $Else