Skip to content

unionTypeGuard<const TTypeGuards>

Builds a guard accepting what any of the given guards accepts.

Import:

import { unionTypeGuard } from '@mnaoumov/typescript-lib/type-guards';

Signature:

function unionTypeGuard(typeGuards: TTypeGuards): TypeGuard<GuardedType<TTypeGuards[number]>>

Parameters:

Parameter Type Description
typeGuards TTypeGuards The guards, tried in order.

Returns: TypeGuard<GuardedType<TTypeGuards[number]>> — The guard.