microsoft / microsoft/TypeScript
JSDoc present in mapped types is not output in generated type literals in declaration files
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた TypeScript Playground を使用して mapped-type 宣言の出力を再現し、生成された .d.ts とソースの JSDoc を比較します。declaration emitter と mapped-type のプロパティ処理を追跡し、生成された型リテラルが JSDoc を保持することを示すカバレッジを追加して、期待される宣言を検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100