microsoft / microsoft/TypeScript

Incorrect docs: type compatibility for functions with overloads

オープン 初心者向け
#30,075 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

説明

Search Terms: functions with overloads, type compatibility

In the docs, it says: "When a function has overloads, each overload in the source type must be matched by a compatible signature on the target type." But it should be "When a function has overloads, each overload in the source type target type must be matched by a compatible signature on the target type source type."

Code
The actual behaviour is right:

type t1 = {
    (foo: string): string
    (foo: number): number
}

type t2 = {
    (foo: string): string
}

declare let v1: t1;
declare let v2: t2;
v2 = v1 // OK
v1 = v2 // Error

The type on the right side of = is considered "the source type".

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

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

はじめの一歩

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

調査の方向性

型の互換性に関するリンク先の TypeScript Handbook のページから始め、オーバーロードの互換性について説明しているセクションを見つけます。記載内容を提示された代入例と比較し、ソース型とターゲット型が一貫して説明されるようにソースドキュメントを更新します。レンダリングされたページと、例に記載された動作を確認します。

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

評価

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

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

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