Replies: 1 comment 7 replies
-
This is technically possible to implement. Typia is an example for this. Do you also have an idea how |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I would like to submit a proposal for enhancing the valibot DX and seamlessly integrate with TypeScript types.
For now, the valibot syntax relies on functions and rewriting all our types as
const
variables or schemas that then are used to validate any input/data to be safely typed both statically and dynamically.Here is the current syntax so far (a very simple example):
As we can see, we have to shift all our types syntax to a variable with functions from valibot in order to have correct validation and everything it has to offer.
Therefore, here is my proposal on how to enhance this. It would be a dream to have this directly inside TypeScript (in some manner) and would resolve a lot of issues.
Here is the same code as above but with a TypeScript interface:
As you can see, the result should be the same as the current valibot syntax. However, it allows for current codebases not using valibot to seamlessly switch to it by validating types dynamically as it can reuse the types it already has rather than making a huge refactoring and switching to variables schemas.
I don't know the details of its implementation. And I'll be happy to hear your thoughts on that proposal !
What do you think about that ?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions