Comments (4)
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
from faunadb-js.
I've been using io-ts for over a year, you don't have to advertise it to me :D
Note this can be easily ensured by io-ts.
This is checked by ts-json-validator at runtime.
"Can't enforce using type system" means "statically typechecked with type inferred from decoder".
All validating for refinement types must be done in userland at runtime unless there's been some recent development in RSC.
ts-json-validator currently supports every keyword, though not all of them contribute to the final derived type.
All good decoder libraries do two things.
- Validate
- Derive a static type
The table you attached is about deriving.
JSON Schema can do a lot, but it isn't turing complete.
There are certainly many use cases, which call for defining(refining) your types with predicates,
what I believe is impossible in ts-json-validator.
I watched this talk from NDC Sydney 2017. I really liked it :)
Did the 2019 version change a lot?
from faunadb-js.
Another example. Note serializeCookie signature requires FaunaSecret type. It can not accept a plain string. t.type({ secret: FaunaSecret })
ensures via its decode method that we really got secret.
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
from faunadb-js.
I'll just leave a note here.
I am aware that io-ts
and fp-ts flavor functional API might not be for everyone.
I believe the idea of parsing data on application boundary to be sound regardless of preferred paradigm.
ts-json-validator
is a nice alternative.
I'm using io-ts
, but I wanted to present you with another option.
Pros
- It uses ajv, so it's crazy fast.
- JSON Schema is pretty standard and the API might be more familar to some people.
Cons
There's a trade-off. It has 10x less stars and the API is subject to change.
The attached chart is from this benchmark.
from faunadb-js.
Related Issues (20)
- provide internal function to "normalize" "data" result
- Property 'requestResult' does not exist on type 'typeof FaunaHTTPError'.
- invalid argument: Regular Class Ref expected, Schema Class Ref provided. HOT 3
- "invalid ref" when using `client.query( Create( Collection('test') ...` HOT 3
- UDF's not showing javascript variables HOT 2
- process.version & process.versions fail build on Vercel Edge API Route HOT 3
- Failing Queries from Cancelled Stream Error HOT 5
- The package "http2" wasn't found on the file system but is built into node HOT 11
- Typechecking functions such as `IsString` should also null as a parameter (typescript typing issue) HOT 2
- 4.7.0 to 4.7.1 causes InvalidValue error when importing code HOT 5
- TypeError: faunadb.Client is not a constructor HOT 10
- Is it safe to expose the key in the browser? HOT 3
- Explictly set 'Content-Type': 'application/json' HOT 1
- OPTIONS xhr request before POST HOT 1
- PageHelper.nextPage() fails to handle the final page HOT 2
- PageHelper.nextPage() throws an error if `size` parameter is passed to `Client.paginate()` HOT 1
- what is the status of the ESM driver? HOT 2
- require('util') fails in some ESM configurations HOT 1
- "TypeError: Incorrect type for the 'signal' field on 'RequestInitializerDict': the provided value is not of type 'AbortSignal'." HOT 1
- Allow login, disable creating account HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from faunadb-js.