Error Inference in Effect Resolvers

Shouldn't the resolver from the effect correctly infer the error? Taken from docs https://effect.website/docs/guides/batching-caching#resolvers-with-context

import { Effect, Context, RequestResolver } from "effect"
import * as Model from "./Model"
import * as Requests from "./Requests"
 
export class HttpService extends Context.Tag("HttpService")<
  HttpService,
  { fetch: typeof fetch }
>() {}
 
// In this signature no Model.GetTodosError is present 
export const GetTodosResolver =
  // we create a normal resolver like we did before
  RequestResolver.fromEffect((request: Requests.GetTodos) =>
    Effect.andThen(HttpService, (http) =>
      Effect.tryPromise({
        try: () =>
          http
            .fetch("https://api.example.demo/todos")
            .then((res) => res.json() as Promise<Array<Model.Todo>>),
        catch: () => new Model.GetTodosError()
      })
    )
  ).pipe(
    // we list the tags that the resolver can access
    RequestResolver.contextFromServices(HttpService)
  )
Effect is a powerful TypeScript library designed to help developers easily create complex, synchronous, and asynchronous programs.
Batching – Effect Docs
Was this page helpful?