Effect CommunityEC
Effect Community3y ago
4 replies
d10

Type Error when passing code into `Scope.extend` with pipe

Hi I'm trying to change this code into using pipe.
const { runtime, destroy } = Effect.runSync(
  Effect.gen(function* ($) {
    const scope = yield* $(Scope.make());
    const runtime = yield* $(
      Layer.toRuntime(appLayer),
      Scope.extend(scope),
    );
    return {
      runtime,
      destroy: Scope.close(scope, Exit.unit),
    };
  }),
);


but getting this type error when I pass it into Scope.extend. Why does it work in the generator function but not pipe?

const scope = Scope.make();
const runtime = pipe(Layer.toRuntime(appLayer), Scope.extend(scope)); // <-- type error here
image.png
Was this page helpful?