Tech
Why Your TypeScript Code Still Crashes in Production: Validating Data at Runtime Boundaries with Zod
Mình từng review một incident lúc 2 giờ sáng: service Node.js crash hàng loạt với lỗi TypeError: Cannot read properties of undefined (reading 'toFixed') . Codebase 100% TypeScript, bật strict: true , CI xanh, không có any nào. Vậy mà vẫn sập. Nguyên nhân là bên đối tác đổi field price từ number sang string "12.50" , và có record thì trả về null . TypeScript không hề biết chuyện này, vì type chỉ tồn tại lúc compile, còn data thật đến lúc runtime .
Bài này chia sẻ cách mình xử lý vấn đ...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to