Function: isErr()
isErr<
T,E>(result):result is Err<E>
Defined in: result/guards/index.ts:41
Type guard to check if a Result is Err.
Narrows the type to Err
Type Parameters
T
T
E
E
Parameters
result
Result<T, E>
The Result to check
Returns
result is Err<E>
True if the Result is Err, false otherwise
Example
const result: Result<number, string> = err('Failed')
if (isErr(result)) {
console.log(result.error) // TypeScript knows this is safe
}