Closed vaderkos closed 3 months ago
I like this. In the meantime, you can use the babel implementation of the partial operator to get what you want without wrapper functions.
I need to document this better, but you can already use:
ArticleStruct.assert(data)
Instead of:
assert(data, ArticleStruct)
I'm not sure we gain much more with currying?
The reason to have the helpers as functional ones at all is unfortunately because we're pushing the limits of what TypeScript is capable of, and TypeScript will error when using Struct.assert(data)
, which I'm fairly sure will also error when using the curried method. (Here's the TypeScript issue tracking the limitation: https://github.com/microsoft/TypeScript/issues/34596)
I take it back, I do see the value in offering currying. Once that upstream TypeScript issue is fixed I'm down to have a breaking change to swap the order of those arguments and add currying. I don't want to do it until then though because I don't want to end up with more parts of the codebase that only work when not using TypeScript.
It seems like the TS issue is not going to be solved. Closing for now.
It would be great if validation functions like is, assert, coerce, validate supported currying and had swapped arguments order.
In that way there would a bit more ways to use superstruct, so bound function can be easily prepared.