5

Fastest Way to Auto Generate Types for Typescript and Input validation

 1 year ago
source link: https://dev.to/seyyedkhandon/fastest-way-to-auto-generate-types-for-typescript-and-input-validation-478p
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Cover image for Fastest Way to Auto Generate Types for Typescript and Input validation
DX Knight

Posted on Apr 22

• Updated on Apr 24

sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg 14 fire-f60e7a582391810302117f987b22a8ef04a2fe0df7e3258a5f49332df1cec71e.svg 1

 

Fastest Way to Auto Generate Types for Typescript and Input validation

Short description

Writing types for API's especially giant JSON's are frustrating especially when it comes to input validation.

solution:

Just paste your json inside app.quicktype.io or it's vscode

Image description

Now you can paste that type into transform.tools/typescript-to-zod to generate the corresponding zod schema for input validation:

Image description

Note 🏅 For Practical step by step example check this 4min youtube video:

Video - Skip Writing types manually

Github Project

Top comments (5)

pic

CollapseExpand

A schema from backend can speed up generating types

Comment button Reply

CollapseExpand

Yeah, but Most of the time schema for 3rd party api's are not available.

Comment button Reply

CollapseExpandCollapseExpand

And what about nullable types? That's why I prefer to stick to the server-side scheme

Comment button Reply

CollapseExpand

It supports that too. bu what do you mean about server side scheme? can you please explain more

Comment button Reply


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK