Issue with Using `transformOrFail` Schema Inside `S.Array()` in Effect-ts Schema

Effect-ts Schema: Can't use transformOrFail schema directly inside S.Array()

I've encountered an error when trying to use a transformation schema directly as an argument to S.Array(). For example:

// This doesn't work
S.Array(MyTransformOrFailSchema) 

When running code with this pattern, I get:

TypeError: Cannot read properties of undefined (reading 'ast')


This seems to be a limitation in how Effect-ts Schema handles composition with array constructors. Has anyone else encountered this? What's the proper pattern for transforming arrays of objects?

So far I've found two workarounds:

- Create a separate transformation specifically for arrays
- Use the base target schema in Array and manually transform elements in the decode function

Any guidance on best practices here would be appreciated!
Was this page helpful?