Creating a Self-Contained Function with Optional Dependencies in Effect Typescript

Hi, how do I do this? I have aself contained function with option to provide dependencies for example

type AvailableService = ServiceA | ServiceB | ServiceC

// result effect type will be Effect.Effect<A, E, AvailableService>
// error and success should be mapped properly.
const effect = fromEffect(
  Effect.gen(function* () {
    const svcA = yield* ServiceA
    const svcD = yield* ServiceD
    const svcE = yield* ServiceE
    
    // ...rest of code...
  }),
  {
    // if there are not extra service then it should be optional, else required those extra services
    dependencies: [ServiceD.Default, ServiceE.Default] // this should give type error as ServiceD and ServiceE is required, unless provided
  }
)


how can i create such a function? I am stuck with types
Was this page helpful?