microsoft / microsoft/TypeScript

Undocumented = operator syntax in Generic Constraining

オープン
#30,337 コメント 4 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Docs
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

In the declaration file for Fastify (https://github.com/fastify/fastify/blob/master/fastify.d.ts) there is some TypeScript code I do not recognize and cannot find another example of in the TypeScript documentation:

declare function fastify<
  HttpServer extends (http.Server | http2.Http2Server) = http.Server,
  HttpRequest extends (http.IncomingMessage | http2.Http2ServerRequest) = http.IncomingMessage,
  HttpResponse extends (http.ServerResponse | http2.Http2ServerResponse) = http.ServerResponse
>(opts?: fastify.ServerOptions): fastify.FastifyInstance<HttpServer, HttpRequest, HttpResponse>;

I recognize the Generic constraint syntax with the extends keyword, but what about the = http.Server part? Is this like a default parameter or something?

Whatever this syntax means it should be better documented.

I tried googling for this syntax by searching

  • typescript generic constraint
  • typescript generic constraint assignment
  • typescript generic defaults

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず Fastify の fastify.d.ts にあるジェネリック宣言を読み、Issue に記載されている TypeScript ドキュメントの検索結果と、その制約およびデフォルト構文を比較します。= http.Server の部分が何を意味するのかを説明し、適切な TypeScript ドキュメントに例または説明を追加します。新しく参加する人がこの構文を見つけて理解できるようになれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
documentation
issue の種類
ドキュメント
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。