requireNotNullish()function
requireNotNullish(value: Nullish<T>, caller: AnyCaller = requireNotNullish): T
| Param | Type | |
|---|---|---|
value | Nullish<T> | The value to require. required |
caller | AnyCaller | Function used to attribute a thrown error to the calling site. Defaults to requireNotNullish |
| Return | |
|---|---|
T | The value, narrowed to T. |
| Throws | |
|---|---|
unknown | RequiredError if value is null or undefined. |
Get the not-nullish version of a value, or throw RequiredError if it is null or undefined.
Examples
requireNotNullish("a") // "a"