colinhacks / zod

TypeScript-first schema validation with static type inference
https://zod.dev
MIT License
33.87k stars 1.18k forks source link

Huge output `.d.ts` files when using `.catchall` with `.passthrough` #2576

Open vmajsuk opened 1 year ago

vmajsuk commented 1 year ago

After upgrading from zod@3.21.0 to zod@3.21.4, output .d.ts files for schemas combining .catchall with .passthrough grew exponentially - on our project for one particular schema it exploded from 350 lines to 70k lines

This is a problem because it causes worse compile performance & GC failures when using tools like webpack.

You can check out a sample case to reproduce the error here (the repo also contains the comparison of output declaration sizes for different errors): https://github.com/vmajsuk/zod-d-ts-regression

divmgl commented 9 months ago

We're also experiencing the same problem. Simple types are repeating the same data structures multiple times.