-
Notifications
You must be signed in to change notification settings - Fork 134
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
TypeScript interface is incomplete #116
Comments
Any update on this? Having the types in the npm package would be helpful so they're always updated. |
I haven't had the bandwidth to work on this yet. |
Would you be open to a PR to improve the built-in types based on |
@rshea0 Yes it would be very much appreciated! We have improved the typings since I opened this issue so I think the typings are mostly accurate now. |
is it expected that e.g. |
@cmdcolin Yes, it is expected but a type-safe interface would be very cool. Do you have any good ideas on how to implement it? |
This is a very nice feature to have. It is not impossible to implement -- data validation libraries have been doing this for quite some time. However, I have been reading Zod's source code (looks like very advanced stuff), but I haven't yet figured out a way to recreate the same effect. Also, there are other validation libraries, it's just that Zod is the one I'm most familiar with. See below for an example using Zod, using the IPv4 header parsing example. Notes:
Example (long block of code)
|
In particular,
ParserOptions
does implement all available options (e.g., length can be a string or function too).The text was updated successfully, but these errors were encountered: