Issue with Config Dependency in Effect-based TypeScript Project Migration

Hi, I'm new to effect and I'm trying to slowly migrate my typescript project to effect. I have core services which are just interfaces, and then infra services which implement these interfaces.
I'm having an issue with reading MyConfig in my infra service, because the MyConfig dependency is not defined in the core service.

MyConfig is a simple wrapper around effect's Config which will die if any of the configs are not found on startup. I dont know if effect has an inbuilt way to handle this behavior.


Example:
/infra/MyConfig.ts
const make = Effect.gen(function* () {
  const API_KEY = yield* Config.string("API_KEY");

  return {
    API_KEY,
  };
}).pipe(Effect.catchTag("ConfigError", Effect.die));

export class MyConfig extends Context.Tag("MyConfig")<MyConfig, typeof make>() {
  static Live = MyConfig.of(make);
}


/core/services/SolveService.ts
export class SolveService extends Context.Tag("SolveService")<
  SolveService,
  {
    readonly searchQuery: (query: string) => Effect.Effect<string>;
  }
>() {}


/infra/services/SolveServiceImpl1
export const SolveServiceImpl1 = SolveService.of({
  searchQuery: (query: string) =>
    Effect.gen(function* () {
      const config = yield* MyConfig
      yield* Console.log("Api key: ", config.API_KEY);
      // make http call using api key to get some response string
      return "Sample response";
    }),
});


Error: Type (query:string) => Effect.Effect<string, never, MyConfig> is not assignable to type (query: string) => Effect.Effect<string, never, never>
Was this page helpful?