Package: effect
Module: Layer
Ensures that a layer’s success type extends a given type ROut.
Details
This function provides compile-time type checking to ensure that the success value of a layer conforms to a specific type constraint.
Example (Constraining layer success types)
import { Layer } from "effect"
declare const FortyTwoLayer: Layer.Layer<42, never, never>
declare const StringLayer: Layer.Layer<string, never, never>
// Define a constraint that the success type must be a number
const satisfiesNumber = Layer.satisfiesSuccessType<number>()
// This works - Layer<42, never, never> extends Layer<number, never, never>
const validLayer = satisfiesNumber(FortyTwoLayer)
// This would cause a TypeScript compilation error:
// const invalidLayer = satisfiesNumber(StringLayer)
// ^^^^^^^^^^^
// Type 'string' is not assignable to type 'number'
Signature
declare const satisfiesSuccessType: <ROut>() => <ROut2 extends ROut, E, RIn>(layer: Layer<ROut2, E, RIn>) => Layer<ROut2, E, RIn>
Since v4.0.0