ITADN

[Feature Request] support zod type documentation

#708Closedandykais 创建于 2025-03-19
A
andykaiscommented
Building off of https://github.com/denoland/deno_doc/issues/113 and https://github.com/denoland/deno_doc/issues/92, since these mentioned that the feature is mostly supported, I wanted to call out that documentation is still fairly limited for type definitions built from zod types. Given this fairly small repro: ```ts import z from 'zod' /** * this is the variable description */ export const Foo = z.object({ /** * this is the field description */ bar: z.string(), }) export const FooType = z.infer<typeof Foo> const foo = Foo.parse({ bar: 1 }) foo.bar ``` You can see that the doc types generated are pretty sparse: <img width="746" alt="Image" src="https://github.com/user-attachments/assets/7f4ef2bf-dbef-4f55-a033-47fc76636519" /> <img width="746" alt="Image" src="https://github.com/user-attachments/assets/477c33ec-a8e9-4b1b-91c0-473b4747e3ef" /> I currently have ~30 different zod parsers defined that I use for type inference across my application https://jsr.io/@forager/core/0.7.3/src/inputs/lib/inputs_types.ts, so the original workaround of creating a type and _then_ an associated zod type to reflect it is quite heavy. Over time there will be many more zod parsers in this library as well. Interestingly, it seems like deno_lsp _does_ support inferring these field docstrings when reading an object directly, which is why I created this issue: <img width="361" alt="Image" src="https://github.com/user-attachments/assets/cb2329b5-6210-4ca5-bbcd-44b440d6f476" /> It does seem to that these docstrings are understood at some level by deno, but I will leave it up to you guys to tell me if this is a general design limitation or not. For my particular use case, it means that the jsr docs for my library are going to not be quite sufficient enough to understand how to use most functions, but by poking around the library locally, they can still find the relevant documentation.
关闭于 2025-04-01 2 条评论