microsoft / microsoft/TypeScript
Function body is not checked against assertion signature
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript Version: 3.7.0-dev.20191002
Search Terms: assertion signatures, asserts, not checked, unchecked, unsound
Code
function assertIsString(x: number | string): asserts x is string {
}
function test(x: number | string) {
assertIsString(x);
x.toUpperCase();
}
test(4);
Expected behavior:
This incorrect empty implementation of assertIsString should not type check, because there are execution paths through assertIsString that don’t narrow the type of x to string as the type of assertIsString should require.
Actual behavior:
No TS errors. Compiled JS code fails at runtime: TypeError: x.toUpperCase is not a function.
Playground Link: Playground nightly isn’t new enough, but maybe it will be by the time you read this: link.
Related Issues:
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された TypeScript の例を再現し、assertion signatures と関数本体のチェックを担当するコンパイラのエントリポイントを調査してください。この issue では、ソースファイルやテストは指定されていません。空の assertIsString 実装が拒否される一方で、有効な assertion 実装は引き続き受け入れられ、例を対象とする regression test がある状態が完了条件です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100