ExcludeReason<E, K>Excludes a specific reason variant by its _tag from an error's reason
field.
When to use
Use when you need the remaining nested reason union type after removing
variants handled by _tag, rather than the enclosing error type.
Details
Returns never if E has no reason field.
Example (Excluding a reason variant)
import type { Types } from "effect"
type RateLimitError = { readonly _tag: "RateLimitError"; readonly retryAfter: number }
type QuotaError = { readonly _tag: "QuotaError"; readonly limit: number }
type ApiError = { readonly _tag: "ApiError"; readonly reason: RateLimitError | QuotaError }
type Result = Types.ExcludeReason<ApiError, "RateLimitError">
// { readonly _tag: "QuotaError"; readonly limit: number }Source effect/Types.ts:11073 lines
export type type ExcludeReason<
E,
K extends string
> = E extends {
readonly reason: infer R
}
? Exclude<
R,
{
readonly _tag: K
}
>
: never
Excludes a specific reason variant by its _tag from an error's reason
field.
When to use
Use when you need the remaining nested reason union type after removing
variants handled by _tag, rather than the enclosing error type.
Details
Returns never if E has no reason field.
Example (Excluding a reason variant)
import type { Types } from "effect"
type RateLimitError = { readonly _tag: "RateLimitError"; readonly retryAfter: number }
type QuotaError = { readonly _tag: "QuotaError"; readonly limit: number }
type ApiError = { readonly _tag: "ApiError"; readonly reason: RateLimitError | QuotaError }
type Result = Types.ExcludeReason<ApiError, "RateLimitError">
// { readonly _tag: "QuotaError"; readonly limit: number }
ExcludeReason<function (type parameter) E in type ExcludeReason<E, K extends string>E, function (type parameter) K in type ExcludeReason<E, K extends string>K extends string> = function (type parameter) E in type ExcludeReason<E, K extends string>E extends { readonly reason: Rreason: infer function (type parameter) RR }
? type Exclude<T, U> = T extends U
? never
: T
Exclude from T those types that are assignable to U
Exclude<function (type parameter) RR, { readonly _tag: K extends string_tag: function (type parameter) K in type ExcludeReason<E, K extends string>K }>
: neverReferenced by 6 symbols