optionalGuard<T>
Widens a guard to also accept undefined, which is what an optional parameter receives when it is left out.
Import:
import { optionalGuard } from '@mnaoumov/typescript-lib/api-contract';Signature:
function optionalGuard(guard: ExpectedTypeGuard<T>): ExpectedTypeGuard<T | undefined>Parameters:
| Parameter | Type | Description |
|---|---|---|
guard |
ExpectedTypeGuard<T> | The guard to widen. |
Returns: ExpectedTypeGuard<T | undefined> — A guard accepting what guard accepts, or undefined.
Links to this page: