Comments (4)
any future plan to consider Zod
as a type provider?
from elysia.
I have been experimenting with TypeBox and Zod back then in the beta day in fact I did ship Zod in some versions before migrating to TypeBox, because I have some problems back then that I don't remember anymore, mainly a performance difference between Zod and TypeBox (see benchmark).
As performance is a critical factor for the server side, and find that TypeBox is a good trade-off for that, I decided that Elysia will be using TypeBox as a primary method, and might support Zod later as I've been focusing on some other areas at the moment.
TypeBox does the validation and also has Static Type Inference which made Eden happens by using Static Type Inference.
You can get type inference using the following code:
import { Elysia, t, type UnwrapSchema } from 'elysia'
const UserSchema = t.Object({
user: t.String()
})
type UserSchema = UnwrapSchema<typeof UserSchema>
Fun fact: I also prefer Zod over TypeBox on the client side.
from elysia.
@Victugord You can get the type similarly to Zod. I would prefer Zod since my whole code base uses it but, this works.
import { Static } from '@sinclair/typebox'
import { t } from 'elysia'
const Test = t.Undefined()
type Test = Static<typeof Test>
from elysia.
Close as we have no plan to migrate to Zod in the near future.
Will re-open once we planned to migrate.
from elysia.
Related Issues (20)
- [Sucrose] warning: unexpected isContextPassToFunction error HOT 2
- The generator's response is actually inconsistent HOT 2
- No overload matches this call HOT 4
- `.guard` doesn't guard anymore with `cookie` (both `aot: true & false`)
- SyntaxError: export 'Html' not found in '@kitajs/html' HOT 3
- Allow multiple handlers with same path in something like guard
- Having "success" or "statusCode" method in handler like "error" to response 201/204 status code.
- request: matrix room HOT 1
- Allow `.derive` to take additional data HOT 2
- Support for route meta HOT 1
- TypeBox errors are stringified instead of returning object
- Support tRPC v11 HOT 1
- Make Elysia easier to maintain and debug by setting aot: false by default
- Error from body-parser when sent `Content-Type` header without body HOT 4
- Sveltekit integration doesn't work
- Consider using ajv instead of typebox for schema validation HOT 2
- MESSY ERROR `NOT FOUND` HOT 4
- Custom errors thrown in `onRequest` do not get proper `code` set in `onError` HOT 2
- Body type will be unknown if strictNullChecks not enabled HOT 1
- Add Default .gitignore to Prevent Committing .env Files HOT 3
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 elysia.