microsoft / microsoft/TypeScript
Destructuring or bracket notation on `never` shouldn't be allowed
Open
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
⏯ 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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