Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Keep alive your typescript definitions using Zod
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Luca Del Puppo
January 16, 2023
Programming
170
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
110
Prisma the ORM that node was waiting for
puppo
0
140
How to scale up your projects like a pro
puppo
0
160
Alive, Tipi Sopravvisuti
puppo
0
150
ReactDay 2022 - Unit testing
puppo
0
150
How to scale up your angular projects like a pro
puppo
0
220
Prisma in the Air
puppo
0
500
Can typescript definitions survive even at runtime?
puppo
0
180
Is it possible to build your UI components using only web components?
puppo
0
130
Other Decks in Programming
See All in Programming
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
120
ActionController meets Protocol Buffers
sorah
1
710
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
240
コーディング自動化の次へ。人の介入をゼロにするファクトリーとサポートAIによる実践
timakin
5
4.7k
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
210
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
320
GraphQL の onError と Nullability のこれから
quramy
0
180
No More NoSuchMethodError
exoego
1
110
AI-Powered Domain-Driven Design
ziobrando
0
320
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
7k
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
1.5k
graphql-ruby を Spinel で速くしようとした話
mtsmfm
0
120
Featured
See All Featured
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
580
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
470
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
280
Ruling the World: When Life Gets Gamed
codingconduct
0
420
Statistics for Hackers
jakevdp
799
230k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
650
New Earth Scene 8
popppiees
4
2.7k
Mind Mapping
helmedeiros
1
410
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
320
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]