Hyperlinkv0.8.0-beta.28

Layer

Layer.satisfiesSuccessTypeconsteffect/Layer.ts:2350
<ROut>(): <ROut2 extends ROut, E, RIn>(
  layer: Layer<ROut2, E, RIn>
) => Layer<ROut2, E, RIn>

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'
utility types
Source effect/Layer.ts:23502 lines
export const satisfiesSuccessType =
  <ROut>() => <ROut2 extends ROut, E, RIn>(layer: Layer<ROut2, E, RIn>): Layer<ROut2, E, RIn> => layer