JSDoc with @extends, type parameter and member expression gives wrong dts output
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 38/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript, typescript
- 領域
- compilers
調査の方向性
リンクされた再現ケースから始め、issue-typescript-missing-type-param をチェックアウトし、npm install と npm run build を実行してから、dist/index.d.ts を調べます。JSDoc @extends の member expression に対する宣言出力の経路を追跡します。生成された extends 句が T 型引数を保持し、宣言が有効であることを確認できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
🔎 Search Terms
jsdoc type parameter generics extends superclass template
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about JSDoc type parameters with
@extends
I tried with TypeScript 5.0.0, 5.6.2, and 5.7.0-dev.20241001.
⏯ Minimal repro link
I needed more than one file to reproduce, which I can't do on the playground. Here's a simple reproducer:
https://github.com/blutorange/issue-repro/tree/issue-typescript-missing-type-param
git clone https://github.com/blutorange/issue-repro
cd issue-repro
git checkout issue-typescript-missing-type-param
npm install
npm run build
Then open dist/index.d.ts.
💻 Code
/**
* @template {0|1|2} T
* @extends {Scope.sub.Box<T>}
*/
export class MyComponent extends Scope.sub.Box {
more() {
return "foo";
}
}
🙁 Actual behavior
The class in the extends clause is missing the type parameter. This is a compile error when you validate the .d.ts file.
declare const MyComponent_base: typeof import("./header.js").Box;
/**
* @template {0|1|2} T
* @extends {Scope.sub.Box<T>}
*/
export class MyComponent<T extends 0 | 1 | 2> extends MyComponent_base {
constructor();
more(): string;
}
export {};
🙂 Expected behavior
TypeScript should include the type parameter in the extends clause.
declare const MyComponent_base: typeof import("./header.js").Box;
/**
* @template {0|1|2} T
* @extends {Scope.sub.Box<T>}
*/
export class MyComponent<T extends 0 | 1 | 2> extends MyComponent_base<T> {
constructor();
more(): string;
}
export {};
Additional information about the issue
Only seems to happen when the extends clause is a member expression where TS generate an intermediate declare const ....
Fyi, I came across this issue while investigating how to setup a project for generating type declarations from js files for primefaces/primefaces#12500
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 15時間
- マージ済み PR(30日)
- 106
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/TypeScript のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
microsoft/TypeScript#64322 · コメント 2 件 · リアクション 1 件 · 担当者 2 名 ·
-
Possible Improvement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/TypeScript#64278 · コメント 1 件 · リアクション 1 件 ·
-
Docs
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
microsoft/TypeScript#64118 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
microsoft/TypeScript#64094 ·
-
Docs
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
microsoft/TypeScript#63959 · コメント 5 件 ·
microsoft/TypeScript の issue をすべて見る
似ている issue
-
Type/Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OpenNSW/nsw-srilanka#497 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
milvus-io/birdwatcher#545 ·
-
kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
kubernetes-sigs/prow#953 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
JuliusBrussee/caveman#1102 · コメント 1 件 ·