Skip to content

createExpectedTypeGuard<T>

Pairs a type guard with what it expects.

Import:

import { createExpectedTypeGuard } from '@mnaoumov/typescript-lib/api-contract';

Signature:

function createExpectedTypeGuard(expected: string, typeGuard: TypeGuard<T>): ExpectedTypeGuard<T>

Parameters:

Parameter Type Description
expected string What the value should have been, phrased to follow “Expected”, e.g. 'a string'.
typeGuard TypeGuard<T> The guard.

Returns: ExpectedTypeGuard<T> — The guard.