PartialEffectful<A>A utility type for creating partial mocks of services in testing.
When to use
Use to type partial test service implementations where only exercised effectful members are stubbed.
Details
This type makes Effect, Stream, and Channel values and functions
returning them optional, while keeping non-effectful properties required.
This allows you to provide only the methods you need to test while leaving
others unimplemented.
export type type PartialEffectful<A extends object> =
{
[K in keyof ({
[K in keyof A as any]?: A[K] | undefined
} & { [K in keyof A as any]: A[K] })]: ({
[K in keyof A as any]?: A[K] | undefined
} & { [K in keyof A as any]: A[K] })[K]
} extends infer B
? B
: never
A utility type for creating partial mocks of services in testing.
When to use
Use to type partial test service implementations where only exercised
effectful members are stubbed.
Details
This type makes Effect, Stream, and Channel values and functions
returning them optional, while keeping non-effectful properties required.
This allows you to provide only the methods you need to test while leaving
others unimplemented.
PartialEffectful<function (type parameter) A in type PartialEffectful<A extends object>A extends object> = 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<
& {
[function (type parameter) KK in keyof function (type parameter) A in type PartialEffectful<A extends object>A as function (type parameter) A in type PartialEffectful<A extends object>A[function (type parameter) KK] extends type AnyEffectOrStream = anyAnyEffectOrStream ? function (type parameter) KK : never]?: function (type parameter) A in type PartialEffectful<A extends object>A[function (type parameter) KK]
}
& {
[function (type parameter) KK in keyof function (type parameter) A in type PartialEffectful<A extends object>A as function (type parameter) A in type PartialEffectful<A extends object>A[function (type parameter) KK] extends type AnyEffectOrStream = anyAnyEffectOrStream ? never : function (type parameter) KK]: function (type parameter) A in type PartialEffectful<A extends object>A[function (type parameter) KK]
}
>