Comments (3)
This package is great for build tools that accept Zod schemas. z.infer
is on the type level, while this package builds a TS type definition just from the schema that a user might pass into a function.
If you're doing type inference, use z.infer
. If you're trying to emit the types from a Zod schema, then use this package.
from zod-to-ts.
Here's an example of a project that uses this package to generate client-side types: https://github.com/sachinraja/trpc-playground. It creates a playground for tRPC users to query their API in the browser. There's no way to do type inference in the browser from local TS files. So it uses zod-to-ts
to generate the types from Zod schemas and send them to tsserver running in the browser.
Might be a slightly confusing explanation but generally:
zod-to-ts
for TS build tools based on Zod schemas
z.infer
for type inference
from zod-to-ts.
Just skimmed your readme again. don't they do exactly the same? Would you mind to elaborate with an example? Highly appreciated and might be also good to have this clarification on you readme.
from zod-to-ts.
Related Issues (20)
- What's the use case? HOT 1
- Does not handle ZodDiscriminatedUnion
- can convert preprocess to ts HOT 1
- export option in createTypeAlias HOT 2
- README should include printNode? HOT 1
- Typescript should be regular dependency HOT 6
- Update to typescript 5 HOT 1
- `nativeEnum()` value with description HOT 2
- Have the option to deeply include zod descriptions as jsdoc comments HOT 1
- Support for TS `Template Literal Types` HOT 1
- Inconsistencies between typescript versions in code and docs(Readme.md)
- Type instantiation is excessively deep and possibly infinite HOT 1
- Debug Failure. Unhandled SyntaxKind: Unknown
- Get input type? HOT 1
- Unable to get the correct type when I used `z.transform()` HOT 1
- .catch() evaluates to any
- Feature request:
- Conversion of `z.nativeEnum()` with negative number fails on TS v5.4
- Default values in jsdoc
- Request: option to include description as comments
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 zod-to-ts.