Effect CommunityEC
Effect Community3y ago
32 replies
bigpopakap

The purpose of providing the target schema in `S.transform`

For S.transform, why do you need to provide the target schema to it? Is it purely to tell the function what Typescript type to use for the output?

Ex.
pipe(
   S.string,
   S.transform(
      // Why do I need this? Is it just so that S.To<> and S.From<> can calculate the type correctly?
      S.array(S.string),

     // I understand why I need to provide these, of course
      str => str.split(":"),
      arr => arr.join(":"),
   ),
)
Was this page helpful?