literalGuard
Builds a guard accepting exactly the listed values.
Import:
import { literalGuard } from '@mnaoumov/typescript-lib/api-contract';Signature:
function literalGuard(literals: Readonly<Record<string, true>> | readonly Literal[]): ExpectedTypeGuard<Literal>Parameters:
| Parameter | Type | Description |
|---|---|---|
literals |
Readonly<Record<string, true>> | readonly Literal[] | The accepted values, as a list or as the keys of a record. |
Returns: ExpectedTypeGuard<Literal> — The guard.