Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Keep alive your typescript definitions using Zod
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Luca Del Puppo
January 16, 2023
Programming
0
140
Keep alive your typescript definitions using Zod
Luca Del Puppo
January 16, 2023
Tweet
Share
More Decks by Luca Del Puppo
See All by Luca Del Puppo
Aware dependencies using Nx Graph
puppo
0
84
Prisma the ORM that node was waiting for
puppo
0
120
How to scale up your projects like a pro
puppo
0
140
Alive, Tipi Sopravvisuti
puppo
0
130
ReactDay 2022 - Unit testing
puppo
0
120
How to scale up your angular projects like a pro
puppo
0
190
Prisma in the Air
puppo
0
430
Can typescript definitions survive even at runtime?
puppo
0
130
Is it possible to build your UI components using only web components?
puppo
0
94
Other Decks in Programming
See All in Programming
2026/02/04 AIキャラクター人格の実装論 口 調の模倣から、コンテキスト制御による 『思想』と『行動』の創発へ
sr2mg4
0
680
株式会社 Sun terras カンパニーデック
sunterras
0
2k
浮動小数の比較について
kishikawakatsumi
0
370
CopilotKit + AG-UIを学ぶ
nearme_tech
PRO
1
120
クライアントワークでSREをするということ。あるいは事業会社におけるSREと同じこと・違うこと
nnaka2992
1
300
The Ralph Wiggum Loop: First Principles of Autonomous Development
sembayui
0
3.7k
CSC307 Lecture 13
javiergs
PRO
0
310
Go 1.26でのsliceのメモリアロケーション最適化 / Go 1.26 リリースパーティ #go126party
mazrean
1
340
TipKitTips
ktcryomm
0
150
「やめとこ」がなくなった — 1月にZennを始めて22本書いた AI共創開発のリアル
atani14
0
350
15年目のiOSアプリを1から作り直す技術
teakun
1
590
Go Conference mini in Sendai 2026 : Goに新機能を提案し実装されるまでのフロー徹底解説
yamatoya
0
510
Featured
See All Featured
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.4k
The Limits of Empathy - UXLibs8
cassininazir
1
240
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
210
The Curious Case for Waylosing
cassininazir
0
260
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
210
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
130
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
140
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
120
Measuring & Analyzing Core Web Vitals
bluesmoon
9
770
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.8k
Transcript
Keep alive your typescript definitions using Zod Luca Del Puppo
Who I am Luca Del Puppo (aka Puppo)
Full-Stack Developer @ Flowing a Claranet Company and Microsoft MVP @puppo92 https://www.linkedin.com/in/lucadelpuppo/
[email protected]
Typescript journey 1
10 years ago
The developers reaction
interface CustomerModel { id: number; name: string; email: string; phone:
string; } Interfaces
type CustomerModel = { id: number; name: string; email: string;
phone: string; }; Types
HTTP Request
But after a while…
➔ Typescript enables type check but on BUILT - TIME
➔ After the build all your types disappears ➔ After the build all your considerations about types dissolve Why?
Prevent ugly mistakes 2
Zod is your super hero
import { z } from ‘zod’; const CustomerSchema = z.object({
id: z.number(), name: z.string(), email: z.string(), phone: z.string(), }); Schema
import { TypeOf } from ‘zod'; type CustomerModel = TypeOf<typeof
CustomerSchema>; Convert to type
const res = CustomerSchema.parse({ id: 1, name: 'John Doe', email:
'
[email protected]
', phone: '555-555-5555' }); Parse method
➔ Parse throws an Error ➔ ZodError is the right
error to check ➔ ZodError contains all the issues that describe the errors Something wrong?
Do you hate exceptions? use safeParse
safeParse Success ➔ success: true ➔ data: Output Error ➔
success: false ➔ error: ZodError
Benefits of using Zod
Create a layer between your app and the outside V
a l i d a t i o n HTTP socket.io
Demo 3
Conclusion 4
➔ Typescript is awesome, but it’s good only on built
time ➔ Create a validation layer between your app and the outside • Prevent execution of code with wrong data • You can get notifications if something is changed ➔ Using Zod, you can guarantee your types, both built-time and run-time Conclusion
CODE SLIDE
Thanks! That’s All! Luca Del Puppo @puppo92 https://www.linkedin.com/in/lucadelpuppo/
[email protected]