@@ -1226,3 +1226,55 @@ export const updateService = dual<
12261226 layer ,
12271227 map ( context ( ) , ( c ) => Context . add ( c , tag , f ( Context . unsafeGet ( c , tag ) ) ) )
12281228 ) )
1229+
1230+ // -----------------------------------------------------------------------------
1231+ // Type constraints
1232+ // -----------------------------------------------------------------------------
1233+
1234+ /**
1235+ * A no-op type constraint that enforces the success channel of a Layer conforms to
1236+ * the specified success type `ROut`.
1237+ *
1238+ * @example
1239+ * import { Layer } from "effect"
1240+ *
1241+ * // Ensure that the layer produces the expected services.
1242+ * const program = Layer.succeed(MyService, new MyServiceImpl()).pipe(Layer.ensureSuccessType<MyService>())
1243+ *
1244+ * @since 3.20.0
1245+ * @category Type constraints
1246+ */
1247+ export const ensureSuccessType =
1248+ < ROut > ( ) => < ROut2 extends ROut , E , RIn > ( layer : Layer < ROut2 , E , RIn > ) : Layer < ROut2 , E , RIn > => layer
1249+
1250+ /**
1251+ * A no-op type constraint that enforces the error channel of a Layer conforms to
1252+ * the specified error type `E`.
1253+ *
1254+ * @example
1255+ * import { Layer } from "effect"
1256+ *
1257+ * // Ensure that the layer does not expose any unhandled errors.
1258+ * const program = Layer.succeed(MyService, new MyServiceImpl()).pipe(Layer.ensureErrorType<never>())
1259+ *
1260+ * @since 3.20.0
1261+ * @category Type constraints
1262+ */
1263+ export const ensureErrorType = < E > ( ) => < ROut , E2 extends E , RIn > ( layer : Layer < ROut , E2 , RIn > ) : Layer < ROut , E2 , RIn > =>
1264+ layer
1265+
1266+ /**
1267+ * A no-op type constraint that enforces the requirements channel of a Layer conforms to
1268+ * the specified requirements type `RIn`.
1269+ *
1270+ * @example
1271+ * import { Layer } from "effect"
1272+ *
1273+ * // Ensure that the layer does not have any requirements.
1274+ * const program = Layer.succeed(MyService, new MyServiceImpl()).pipe(Layer.ensureRequirementsType<never>())
1275+ *
1276+ * @since 3.20.0
1277+ * @category Type constraints
1278+ */
1279+ export const ensureRequirementsType =
1280+ < RIn > ( ) => < ROut , E , RIn2 extends RIn > ( layer : Layer < ROut , E , RIn2 > ) : Layer < ROut , E , RIn2 > => layer
0 commit comments