Skip to content

Type Alias: FlattenErr<T>

FlattenErr<T> = T extends Err<infer R> ? R : T

Defined in: index.ts:212

Extracts the error from Err types, leaving non-Err types unchanged.

Type Parameters

T

T

The type to potentially flatten

Example

typescript
type T1 = FlattenErr<Err<string>>; // string
type T2 = FlattenErr<string>; // string (unchanged)
type T3 = FlattenErr<Ok<number>>; // Ok<number> (unchanged)
type T4 = FlattenErr<Err<ApiError> | string | Ok<User>>; // ApiError | string | Ok<User>