requireNotNullish()function

requireNotNullish(value: Nullish<T>, caller: AnyCaller = requireNotNullish): T
ParamType
valueNullish<T>
The value to require. required
callerAnyCaller
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"