|
|
|
|
|
by __jonas
427 days ago
|
|
Maybe I'm misunderstanding some aspect here, but it seems to me there are two choices for handling external data in TypeScript: Either you parse / validate incoming data at an API boundary with a tool like zod, or you do not, and just trust that the data matches the exact shape you expect, opening yourself up to completely unexpected errors / behaviors if it does not. The latter is probably a decent option if you fully control all components back to front, but if you really value type safety, the former seems like the way to go? |
|
To me it is bending the original tool (JS, async driven, weak typing) to fit a purpose it was not made for (hard typing, synchronous) in detriment of what it is that makes the tool good in the first place (IO performance).