OmitReason<E, K>Narrows an error's reason field to exclude a specific reason variant by
its _tag.
When to use
Use to narrow the error to only the remaining reason variants after excluding the matched one.
Details
Returns never if E has no reason field or no remaining variants.
Example (Omitting 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.OmitReason<ApiError, "RateLimitError">
// ApiError & { readonly reason: { readonly _tag: "QuotaError"; readonly limit: number } }Source effect/Types.ts:10694 lines
export type type OmitReason<
E,
K extends string
> = E extends {
readonly reason: infer R
}
? R extends {
readonly _tag: infer T
}
? K extends T
? never
: E & {
readonly reason: R
}
: never
: never
Narrows an error's reason field to exclude a specific reason variant by
its _tag.
When to use
Use to narrow the error to only the remaining reason variants after
excluding the matched one.
Details
Returns never if E has no reason field or no remaining variants.
Example (Omitting 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.OmitReason<ApiError, "RateLimitError">
// ApiError & { readonly reason: { readonly _tag: "QuotaError"; readonly limit: number } }
OmitReason<function (type parameter) E in type OmitReason<E, K extends string>E, function (type parameter) K in type OmitReason<E, K extends string>K extends string> = function (type parameter) E in type OmitReason<E, K extends string>E extends { readonly reason: Rreason: infer function (type parameter) RR }
? function (type parameter) RR extends { readonly _tag: T_tag: infer function (type parameter) TT } ? function (type parameter) K in type OmitReason<E, K extends string>K extends function (type parameter) TT ? never : function (type parameter) E in type OmitReason<E, K extends string>E & { readonly reason: Rreason: function (type parameter) RR }
: never
: neverReferenced by 6 symbols