zod icon indicating copy to clipboard operation
zod copied to clipboard

Question: TypeScript Isolated Declarations

Open aminpaks opened this issue 1 year ago • 1 comments

Hi folks,

Firstly, thanks for all the work you've done building such a great project. We're wondering what you have plan for making a lighter type annotations for projects using isolated declarations. We tried Zod with the current version, and explicitly type annotating the module exports are not easy to maintain.

What are you thoughts?

aminpaks avatar Sep 11 '24 20:09 aminpaks

I'm also interested in this, although I don't see a good way of reconciling Zod with isolated declarations since the whole point of Zod is that it will automatically keep the type in sync with the schema.

JavaScriptBach avatar Oct 01 '24 17:10 JavaScriptBach

Hi, @aminpaks. I'm Dosu, and I'm helping the Zod team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • You raised a question about implementing lighter type annotations in TypeScript projects using isolated declarations.
  • The challenge is maintaining explicit type annotations with Zod, which aims to automatically synchronize types with schemas.
  • @JavaScriptBach expressed interest but noted the difficulty of aligning Zod with isolated declarations.
  • @hen-x showed support for the discussion with a thumbs-up reaction.

Next Steps:

  • Please let us know if this issue is still relevant to the latest version of Zod. If so, feel free to comment to keep the discussion open.
  • If there is no further activity, this issue will be automatically closed in 14 days.

Thank you for your understanding and contribution!

dosubot[bot] avatar Jul 24 '25 16:07 dosubot[bot]

This is still very relevant

bradzacher avatar Jul 24 '25 21:07 bradzacher

FWIW VS Code will infer the type annotation of the zod schema from the quick fix menu, so every time you change the zod schema you can re-infer the ts type.

The experience is not great but it’s certainly better than manually keeping the zod schema in sync with a hard coded ts type.

altano avatar Jul 24 '25 21:07 altano

Hi @colinhacks, the user @altano has provided an update indicating that VS Code can infer type annotations from the Zod schema, which improves the experience of keeping types in sync. Could you please assist them further with their question about implementing lighter type annotations in TypeScript projects? Thank you!

dosubot[bot] avatar Jul 24 '25 21:07 dosubot[bot]

He, this is still an issue...

Mikescops avatar Nov 03 '25 16:11 Mikescops