Type Error in Generic Schema Function with Transforms in TypeScript

I'm struggling a bit with generic Schema functions with transforms.
This gives me the right output types, but I get a type error inside my decode function:
const ResponseSchema =  <TSchema extends S.Schema.Any>(BodySchema: TSchema) => S.Struct({
  status: S.Number,
  body: BodySchema
}).pipe(S.transform(
  BodySchema,
  {
    decode: (resp) => resp.body,
    encode: (_) => null as any
  }
))

const SpecificSchema = ResponseSchema(S.Struct({foo: S.String}))


Property 'body' does not exist on type 'Simplify<Type<{ status: typeof Number$; body: TSchema; }>>'.
Was this page helpful?