Error<T>A utility type to extract the error type from a Request.
Example (Extracting a request error type)
import type { Request } from "effect"
interface GetUser extends Request.Request<string, Error> {
readonly id: number
}
// Extract the error type from a Request using the utility
type UserError = Request.Error<GetUser> // Errorutility types
Source effect/Request.ts:1401 lines
export type type Error<
T extends Request<any, any, any>
> = [T] extends [
Request<infer _A, infer _E, infer _R>
]
? _E
: never
A utility type to extract the error type from a Request.
Example (Extracting a request error type)
import type { Request } from "effect"
interface GetUser extends Request.Request<string, Error> {
readonly id: number
}
// Extract the error type from a Request using the utility
type UserError = Request.Error<GetUser> // Error
Error<function (type parameter) T in type Error<T extends Request<any, any, any>>T extends interface Request<out A, out E = never, out R = never>A Request<A, E, R> is a request from a data source for a value of type A
that may fail with an E and have requirements of type R.
Example (Defining typed requests)
import type { Request } from "effect"
// Define a request that fetches a user by ID
interface GetUser extends Request.Request<string, Error> {
readonly _tag: "GetUser"
readonly id: number
}
// Define a request that fetches all users
interface GetAllUsers extends Request.Request<ReadonlyArray<string>, Error> {
readonly _tag: "GetAllUsers"
}
Request<any, any, any>> = [function (type parameter) T in type Error<T extends Request<any, any, any>>T] extends [interface Request<out A, out E = never, out R = never>A Request<A, E, R> is a request from a data source for a value of type A
that may fail with an E and have requirements of type R.
Example (Defining typed requests)
import type { Request } from "effect"
// Define a request that fetches a user by ID
interface GetUser extends Request.Request<string, Error> {
readonly _tag: "GetUser"
readonly id: number
}
// Define a request that fetches all users
interface GetAllUsers extends Request.Request<ReadonlyArray<string>, Error> {
readonly _tag: "GetAllUsers"
}
Request<infer function (type parameter) _A_A, infer function (type parameter) _E_E, infer function (type parameter) _R_R>] ? function (type parameter) _E_E : neverReferenced by 13 symbols