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
Luca Del Puppo
January 16, 2023
Programming
150
0
Share
Keep alive your typescript definitions using Zod
Luca Del Puppo
January 16, 2023
More Decks by Luca Del Puppo
See All by Luca Del Puppo
Aware dependencies using Nx Graph
puppo
0
90
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
200
Prisma in the Air
puppo
0
450
Can typescript definitions survive even at runtime?
puppo
0
140
Is it possible to build your UI components using only web components?
puppo
0
100
Other Decks in Programming
See All in Programming
AI-DLC Deep Dive
yuukiyo
9
5.6k
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
360
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
140
Claude CodeでETLジョブ実行テストを自動化してみた
yoshikikasama
0
1.2k
My daily life on Ruby
a_matsuda
3
190
Agent Skills を社内で育てる仕組み作り
jackchuka
1
1.6k
実践ハーネスエンジニアリング:ステアリングループを実例から読み解く / Practical Harness Engineering: Understanding Steering Loops Through Real-World Examples
nrslib
5
4.5k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
190
[RubyKaigi 2026] Require Hooks
palkan
1
300
20260514_its_the_context_window_stupid.pdf
heita
0
650
Firefoxにコントリビューションして得られた学び
ken7253
2
160
いつか誰かが、と思っていた フロントエンド刷新5年間の実践知
kiichisugihara
1
260
Featured
See All Featured
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
55k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
1.3k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
300
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
180
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
170
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
10k
First, design no harm
axbom
PRO
2
1.2k
Become a Pro
speakerdeck
PRO
31
5.9k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
910
Building AI with AI
inesmontani
PRO
1
970
How to Ace a Technical Interview
jacobian
281
24k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
280
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]