Type Alias IsTemplateLiteral<T, $O>

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

🎭 validate

Validate if T is a template literal(s).

Type Parameters

type R = IsTemplateLiteral<string> // false
type R = IsTemplateLiteral<'foo'> // false
type R = IsTemplateLiteral<`a${number}`> // true

type R = IsTemplateLiteral<`a${number}` | `${bigint}c`> // true

type R = IsTemplateLiteral<never> // false
type R = IsTemplateLiteral<unknown> // false
type R = IsTemplateLiteral<`${number}` | boolean> // boolean

🔢 customize

Filter to ensure T is a template literal(s), otherwise returns never.

type R = IsTemplateLiteral<`${number}`, { selection: 'filter' }> // `${number}`
type R = IsTemplateLiteral<'a', { selection: 'filter' }> // never

🔢 customize:

Disable distribution of union types.

type R = IsTemplateLiteral<`${number}` | 1> // boolean
type R = IsTemplateLiteral<`${number}` | 1, { distributive: false }> // false

🔢 customize

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

type R = IsTemplateLiteral<`${number}`, $IsTemplateLiteral.$Branch> // $Then
type R = IsTemplateLiteral<bigint, $IsString.$Branch> // $Else