Function: assertSuccess()
assertSuccess<
R>(result):trueextendsHasPromise<R> ?Promise<Success<InferSuccess<R>>> :Success<InferSuccess<R>>
Asserts that a Result or ResultAsync is a Success and returns it.
This function requires that the result's error type is never, meaning the result is
guaranteed to be a Success at the type level.
If the result is a Failure at runtime, throws an error.
Type Parameters
R
R extends ResultMaybeAsync<any, never>
The result type that extends ResultMaybeAsync with never as the error type.
Parameters
result
R
The Result or ResultAsync to assert as a Success.
The error type must be never.
Returns
true extends HasPromise<R> ? Promise<Success<InferSuccess<R>>> : Success<InferSuccess<R>>
The Success result or a Promise of Success result.
Throws
If the result is a Failure at runtime.
Examples
See
unwrap - Use with assertSuccess to safely unwrap success values.
