microsoft / microsoft/TypeScript
Poor error recovery when `enum` is used as a parameter name
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
TypeScript Version: 3.6.2
Search Terms: expression expected reserved word
Code
function converter<Enum>(values: string[], enums: Enum[]): Map<Enum, string> {
return new Map<Enum, string>(
enums.map((enum: Enum, index: number) => [ enum, values[index] ])
);
}
Expected behavior:
After some confusion why this displays so many red curlies, the error should make it clear to me that the reserved word enum is accidentaly being used as an argument name. An error is given on enum saying something along the lines of You cannot use enum as a variable/argument because it is a reserved word.
Actual behavior:
After a LOT of confusion, one realizes that the reserved word enum is accidentally being used as an argument name. An error is given on several parts in the above code, where the most helpful one is Expression expected (ts1109), which is just unnecesarily confusing.
Related Issues:
None that seem related.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供されたコードを TypeScript 3.6.2 Playground で使って診断を再現し、その後、パラメーター名 enum 周辺で発生する parser のエラーを比較します。予約語の誤用を特定しつつ、混乱を招く連鎖的な診断を発生させないように報告されるエラーを改善し、同じ例で結果を検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 42/100