microsoft / microsoft/TypeScript
JSDoc present in mapped types is not output in generated type literals in declaration files
还没有人认领这个 Issue。
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
🔎 Search Terms
generated declaration files mapped types jsdoc missing
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about: I don't believe the FAQ contains anything applicable to this.
⏯ Playground Link
💻 Code
This is not the same issue as https://github.com/microsoft/typescript/issues/50715, that issue is about type mappings that lose the JSDoc period.
I'm talking about what happens in the .d.ts file generated for source like this where JSDoc does survive type mapping:
import z from 'zod'
export const schema = z.object({
/**
* Some nice JSDoc
*/
foo: z.string(),
})
const x = schema.parse({foo: 'a'}).foo
// ^^^ hovering foo shows the JSDoc
🙁 Actual behavior
Hovering the parsed .foo in the source file displays the JSDoc for the property:
But if I consume the same type from the generated .d.ts file, I don't get the JSDoc:
🙂 Expected behavior
We should get the same JSDoc when consuming the .d.ts file as we do when consuming the source file it was generated from.
Additional information about the issue
If we look at the generated .d.ts the problem is clear: tsc isn't outputting JSDoc it has in memory for mapped type properties to the generated type literals:
import z from 'zod';
export declare const schema: z.ZodObject<{
/**
* Some nice JSDoc
*/
foo: z.ZodString;
}, "strip", z.ZodTypeAny, {
foo: string; // (tsc should have copied the JSDoc to this property)
}, {
foo: string; // (and to this one)
}>;
//# sourceMappingURL=Schema.d.ts.map
It would at least be nice to have an option to output these copies of JSDoc, even though it would make the declaration file bigger.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用链接的 TypeScript Playground 重现 mapped-type 声明输出,并将生成的 .d.ts 与源代码中的 JSDoc 进行比较。跟踪 declaration emitter 和 mapped-type 属性处理,然后添加覆盖,表明生成的类型字面量会保留 JSDoc,并验证预期的声明。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100