microsoft / microsoft/TypeScript
TypeScript not enforcing the return type of optional methods defined in interfaces implemented by parents of classes
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
TypeScript Version: 3.5.0 (Also tried 3.4.1, 3.0.1, and 2.4.1)
Search Terms: Inheritance, interface, return type, parent, child, override, overload, abstract, optional method, optional interface, implements, extends
Code
interface Mx {
aMethod?(): number;
}
abstract class Base implements Mx {
}
class Child extends Base {
public aMethod() {
return 'hello world';
}
}
Expected behavior:
TypeScript tells me that the return type for Child#aMethod is wrong.
This behaviour is achieved if I add implements Mx on the Child class.
Actual behavior:
TypeScript tells me nothing! It feels that Child#aMethod is well within its rights to return a string.
Playground Link: linky!
Related Issues: I didn't really find any similar looking issues?
The result is this could maybe relate to #22815
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、リンクされた TypeScript Playground の例を再現し、次に Child が Mx を明示的に実装しているバージョンと比較します。TypeScript が冗長な implements 句を要求せずに、Child#aMethod の互換性のない string 戻り値の型を報告すれば、作業は完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100