Giter Club home page Giter Club logo

Comments (3)

sachinraja avatar sachinraja commented on June 6, 2024 1

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.

sachinraja avatar sachinraja commented on June 6, 2024 1

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.

205g0 avatar 205g0 commented on June 6, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.