Issue with TypeScript Utility for JSON Parsing Using Schema

Here I am, miserably failing with another trivial task...If I want to build an utility that takes any request, and tries to parse the JSON using the provided schema... how should I type it? This is my attempt:
export const parseBody = <A>(
  context: APIContext,
  schema: Schema.Schema<A, any>,
) =>
  Effect.tryPromise({
    try: (_) => context.request.json(),
    catch: InvalidBody.make,
  }).pipe(Schema.decode(schema), Effect.mapError(InvalidBody.make))
// And the expected usage, as simple as this
const comment = yield* parseBody(context, Schema.String);
Was this page helpful?