microsoft / microsoft/TypeScript
Named Tuple elements should allow reserved words as their names
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Bug Report
🔎 Search Terms
tuple elements label reserved word
named tuple elements
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about "Common "Bugs" That Aren't Bugs"
⏯ Playground Link
Playground link with relevant code
💻 Code
type x = [if: any]
// but some keywords are allowed, e.g.
type y = [void: any]
🙁 Actual behavior
Unused label.
'any' only refers to a type, but is being used as a value here.
Type expected.
'(' expected.
Unexpected keyword or identifier.
Declaration or statement expected.
🙂 Expected behavior
No errors. As a label it should allow any identifiers, including reserved words.
👩💻 Possible solution
Although parseTupleElementNameOrTupleElementType allows any identifier as its name:
before it is invoked, the isListElement requires a tuple member start a type:
This is no longer true after we support named tuple member after 4.0, which should start with any valid identifiers / keywords. Because isListElement returns false, the parser does not parse them as tuple elements, which results to confusing parsing errors.
We can create a new ParsingContext for named tuple members, and returns token() === SyntaxKind.CommaToken || tokenIsIdentifierOrKeyword(token()) in isListElement.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
src/compiler/parser.ts の isListElement と parseTupleElementNameOrTupleElementType から始め、リンク先の Playground コードを再現手順として使用します。予約語で始まる名前付きタプルメンバーがどのように分類されるかを追跡し、その後、例を対象とするリグレッションテストを追加して、パースエラーが発生しないことを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 50/100