Why we list Zod as a dependency and not as a peer dependency
Blog post from Speakeasy
Speakeasy-generated TypeScript SDKs list Zod as a regular dependency instead of a peer dependency to enhance runtime validation, ensure compatibility, and simplify installation processes, thus maintaining type safety between API responses and TypeScript types. This decision allows the SDKs to operate independently of the project's existing Zod version, providing both backward and forward compatibility, and avoiding potential runtime errors associated with peer dependencies. The approach prevents issues that arise from version conflicts, as different packages can use different Zod versions without interfering with each other, thanks to modern package managers' ability to deduplicate dependencies. This setup ensures that the SDKs remain functional even when projects use incompatible Zod versions, allowing for seamless integration and reliable performance across diverse project configurations.