(
args: Types.VoidIfEmpty<
Types.Simplify<Omit<R, T | keyof Variance<any, any, any>>>
>
): RThe constructor type returned by Request.of and Request.tagged.
Details
The constructor accepts the request's data fields, excluding request variance
fields and any fields already supplied by the constructor such as _tag, and
returns a value of the request type.
Example (Using generated request constructors)
import { Request } from "effect"
interface GetUser extends Request.Request<string, Error> {
readonly _tag: "GetUser"
readonly id: number
}
// Constructor type is used internally by Request.of() and Request.tagged()
const GetUser = Request.tagged<GetUser>("GetUser")
const userRequest = GetUser({ id: 123 })export interface interface Constructor<R extends Request<any, any, any>, T extends keyof R = never>The constructor type returned by Request.of and Request.tagged.
Details
The constructor accepts the request's data fields, excluding request variance
fields and any fields already supplied by the constructor such as _tag, and
returns a value of the request type.
Example (Using generated request constructors)
import { Request } from "effect"
interface GetUser extends Request.Request<string, Error> {
readonly _tag: "GetUser"
readonly id: number
}
// Constructor type is used internally by Request.of() and Request.tagged()
const GetUser = Request.tagged<GetUser>("GetUser")
const userRequest = GetUser({ id: 123 })
Constructor<function (type parameter) R in Constructor<R extends Request<any, any, any>, T extends keyof R = never>R 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 Constructor<R extends Request<any, any, any>, T extends keyof R = never>T extends keyof function (type parameter) R in Constructor<R extends Request<any, any, any>, T extends keyof R = never>R = never> {
(args: Types.VoidIfEmpty<
Types.Simplify<
Omit<R, T | keyof Variance<any, any, any>>
>
>
args: import TypesTypes.type VoidIfEmpty<S> =
keyof S extends never ? void : S
Conditional type that returns void if S is an empty object type,
otherwise returns S.
When to use
Use to erase an empty object type from an API result or parameter position.
VoidIfEmpty<import TypesTypes.type Simplify<A> = {
[K in keyof A]: A[K]
} extends infer B
? B
: never
Flattens an intersection type into a single object type for readability.
When to use
Use to clean up IDE tooltips that show A & B & C instead of a merged
object.
Details
Does not change the type semantically, only its display.
Example (Simplifying an intersection)
import type { Types } from "effect"
// Without Simplify: IDE shows { a: number } & { b: string }
// With Simplify: IDE shows { a: number; b: string }
type Clean = Types.Simplify<{ a: number } & { b: string }>
Simplify<type Omit<T, K extends keyof any> = {
[P in Exclude<keyof T, K>]: T[P]
}
Construct a type with the properties of T except for those in type K.
Omit<function (type parameter) R in Constructor<R extends Request<any, any, any>, T extends keyof R = never>R, function (type parameter) T in Constructor<R extends Request<any, any, any>, T extends keyof R = never>T | keyof (interface Variance<out A, out E, out R>Variance marker carried by every Request.
Details
This marker preserves the success, error, and service requirement types for
Effect's type-level machinery. Users normally get it by extending Request.
Variance<any, any, any>)>>>): function (type parameter) R in Constructor<R extends Request<any, any, any>, T extends keyof R = never>R
}