microsoft / microsoft/TypeScript

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

Open
#42,999 1 comment 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked TypeScript Playground examples and compare property access, bracket notation, and destructuring on a value asserted as never. Trace the compiler's handling of these three forms and add or update regression coverage so each is rejected consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.