Transformation continuations
As we discussed in the previous issue, using a "continuation passing style" seems to be the most natural js solution for further transformations, i.e.:
optional(string, s => s ?? '')
As a side note, this is for all intents and purposes function composition, in pseudo code: optional(string) >> (s => s ?? ''). Since there is no good way of doing this in js directly, this seems like a good compromise.
This is how field and fields already work, and I imagine it will work well with optional, array, record and so on. Unfortunately I don't think it would work with union, as that function already uses variadic overloads and I don't see a way to shoehorn this into it. Not sure if there are more of these cases? It's not a huge problem, just maybe confusing to the user - consistency in the api is good for discoverability.