Type Error in `a5MutateTuple` Function: Context Type Mismatch

Trying to build a little wrapper around some generic async functions that take a tuple of inputs:
export function a5MutateTuple<I extends Schema.TupleType.Elements, R, RA>(params: {
  inputSchema: Schema.Tuple<I>
  responseSchema: Schema.Schema<R, RA>
  mutateFn: (...input: Schema.Schema.Type<Schema.Tuple<I>>) => Promise<R>
  onSuccessE?: (result: R) => Effect.Effect<R>
  onErrorE?: (error: string | ParseError | UnknownException) => Effect.Effect<unknown>
}): (...input: Schema.Schema.Type<Schema.Tuple<I>>) => Promise<R> {
  const {
    inputSchema,
    responseSchema,
    mutateFn,
    onSuccessE = Effect.succeed,
    onErrorE = Effect.succeed,
  } = params

  return (...input) =>
    Effect.runPromise(
      pipe(
        input,
        Schema.decodeUnknown(inputSchema, {
          onExcessProperty: 'preserve',
        }),
        Effect.flatMap((...x) =>
          Effect.gen(function* () {
            return yield* a5E(async () => await mutateFn(...x))
          }),
        ),
        Effect.flatMap(
          Schema.decodeUnknown(responseSchema, {
            onExcessProperty: 'preserve',
          }),
        ),
        Effect.tap(onSuccessE),
        Effect.tapError(onErrorE),
        Effect.tapError((x) =>
          Effect.logError('a5Mutate failed', {
            cause: x,
            input,
          }),
        ),
      ),
    )
}


I am running into the following type error and pulling my hair out:
typecheck: shared/test.ts:104:7 - error TS2345: Argument of type 'Effect<R, string | UnknownException | ParseError, Context<I[number]>>' is not assignable to parameter of type 'Effect<R, string | UnknownException | ParseError, never>'.
typecheck:   Type 'Context<I[number]>' is not assignable to type 'never'.
typecheck:     Type 'unknown' is not assignable to type 'never'.
Was this page helpful?