microsoft / microsoft/TypeScript

Destructuring or bracket notation on `never` shouldn't be allowed

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

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

Awaiting More Feedback Suggestion
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

Bug Report

You can destructure or use bracket notation on never type, but you can't access props using the dot notation. It should disallow all forms of property access.

🔎 Search Terms

never destructuring destructure bracket dot notation

🕗 Version & Regression Information
  • This is the behavior in every version I tried, and I reviewed the FAQ ✔️
⏯ Playground Link

Playground link

🙁 Actual behavior
const { prop } = ({} as never); // does not error
const prop2 = ({} as never)["prop"]; // does not error
🙂 Expected behavior

TS should not allow this, same as you can't access props using the dot notation:

const prop = ({} as never).prop; // error

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

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

はじめの一歩

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

調査の方向性

リンクされている TypeScript Playground の例から始め、never としてアサートされた値に対するプロパティアクセス、ブラケット記法、分割代入を比較してください。コンパイラーがこれら 3 つの形式をどのように処理するかを追跡し、それぞれが一貫して拒否されるように回帰テストを追加または更新してください。

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

評価

技術スタック
typescript
領域
compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

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

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