-
Notifications
You must be signed in to change notification settings - Fork 76
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 version #254
Comments
Another example. Note serializeCookie signature requires FaunaSecret type. It can not accept a plain string. Maybe this stuff (Either and algebraic types composition and functional domain modeling) is new for you. It's much easier than it looks. And super useful. And available in TypeScript. I highly recommend the first five minutes of this talk: https://www.youtube.com/watch?v=PLFl95c-IiU |
I'll just leave a note here. I am aware that
I'm using Pros
ConsThere's a trade-off. It has 10x less stars and the API is subject to change. The attached chart is from this benchmark. |
The performance of io-ts is a non-issue. And nobody is supposed to be forced to use it. It's about how types should be defined. io-ts first ensures we can have reliable runtime-type checking for people who needs it. With Either. Performance micro-optimization is orthogonal. Note this can be easily ensured by io-ts. That's the point. Check https://www.youtube.com/watch?v=PLFl95c-IiU |
I've been using io-ts for over a year, you don't have to advertise it to me :D
This is checked by ts-json-validator at runtime. All validating for refinement types must be done in userland at runtime unless there's been some recent development in RSC.
All good decoder libraries do two things.
The table you attached is about deriving. JSON Schema can do a lot, but it isn't turing complete. I watched this talk from NDC Sydney 2017. I really liked it :) |
Upcoming TypeScript version is a chance to do things right. Sure we can have typed API with TypeScript compiler checking the right composition, that's standard, but we should be able to enforce types even for runtime. Fauna is awesome but as any document DB, any shape approach can accidentally harm the developer. In the end, we need types. But can we blindly believe that our database will return what we expect? Never. Any serious application needs to validate/parse values out of the application boundary. Period.
That's why https://github.com/gcanti/io-ts is such an awesome library. Mature, well-tested, well-designed.
I highly recommend to check it and use it for development TypeScript version of faunadb driver.
For example, this is the FaunaID type I am using. And I will need FaunaRef generic type. And types for Fauna errors. Etc.
I would love to help with any issue regarding TypeScript version design.
The text was updated successfully, but these errors were encountered: