Function: isOk()
Call Signature
isOk<
T
>(result
):result is Ok<T>
Defined in: index.ts:288
Type guard that checks if a Result is an Ok (successful) result.
Type Parameters
T
T
The type of the success data
Parameters
result
Result
<T
, unknown
>
The Result to check
Returns
result is Ok<T>
True if the result is Ok, false if it's Err
Example
typescript
const r: Result<string, Error> = ok("hello");
if (isOk(r)) {
// r is now typed as Ok<string>
console.log(result.data); // "hello"
}
Call Signature
isOk<
R
>(result
):result is Extract<R, Ok<any>>
Defined in: index.ts:289
Type guard that checks if a Result is an Ok (successful) result.
Type Parameters
R
R
extends UnknownResult
Parameters
result
R
The Result to check
Returns
result is Extract<R, Ok<any>>
True if the result is Ok, false if it's Err
Example
typescript
const r: Result<string, Error> = ok("hello");
if (isOk(r)) {
// r is now typed as Ok<string>
console.log(result.data); // "hello"
}