microsoft / microsoft/TypeScript

Enum declarations should consistently disallow computed keys

オープン
#42,468 コメント 6 件 リアクション 4 件 担当者 0 名 GitHub で見る

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

Bug Domain: Error Messages
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

Bug Report

🔎 Search Terms
  • Computed property names are not allowed in enums
  • enum declaration computed
🕗 Version & Regression Information
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about enums
⏯ Playground Link

Playground link with relevant code

💻 Code
let y = "y";
type z = "z";

enum Foo {
    ['x'],
    [{}],
    [y],
    [z]
}
🙁 Actual behavior

TS reports Computed property names are not allowed in enums. for [{}], [y] and [z], while it allows ['x'] (in contraddiction with the error message).

🙂 Expected behavior

All of them should be an error, for the reason reported by the error.

📚 Context

This came up at https://github.com/babel/babel/issues/12683: we can implement the current TS behavior in Babel, but I'd first like to check if TS is expected to report an error for ['x'].

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

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

はじめの一歩

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

調査の方向性

リンクされた TypeScript Playground の動作を、['x']、[{}]、[y]、[z] を使った enum のサンプルで再現する。その例の enum の計算プロパティ診断を追跡する。完了条件は、4 つすべての宣言が一貫して報告されたエラーを生成し、示されたケースをカバーすることである。

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

評価

技術スタック
typescript
領域
compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
35/100

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

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