-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variadic Any Typed function parameters #931
Comments
@eddie-atkinson Hi, Function rest parameters are not currently supported in TypeBox, but are being considered in later revisions. Currently the Type.Rest function only extracts variadic types from Intersect, Union, Tuple structures and returns the interior There are intentions to repurpose Rest for your exact use case, and have been prototyping this feature somewhat recently, however this would be a breaking change as it involves promoting the Rest function result as an actual type that can be remapped on functions and constructors. The eventual API for this will look as follows. const F = Type.Function([Type.Rest(Type.String())], Type.Void())
type F = Static<typeof F> // type F = (...arg: string[]) => void Note, I don't expect this to be ready for some time, but will be aiming for a significant revision near the end of the year. Have marked this issue as Hope this brings some insight |
Hi @sinclairzx81, Many thanks for taking the time to respond, I always appreciate the depth of your answers - it makes for excellent documentation. Looking forward to seeing this feature supported at some point, best of luck with the next version |
Hi there,
First of all huge thanks for creating this library. I am in awe of how many thorny cases you've considered and covered whilst maintaining a user friendly but principled interface.
I am attempting to represent a logging interface using Typebox and am running into some issues with variadic parameters:
The suggestion from the Typebox workbench is something like this:
However that type resolves to something like:
Which isn't quite right
The text was updated successfully, but these errors were encountered: