Skip to content

nullableTypeGuard<T>

Widens a guard to also accept null.

Import:

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

Signature:

function nullableTypeGuard(isValue: TypeGuard<T>): TypeGuard<T | null>

Parameters:

Parameter Type Description
isValue TypeGuard<T> The guard to widen.

Returns: TypeGuard<T | null> — A guard accepting what isValue accepts, or null.