Skip to content

Destructuring or bracket notation on never shouldn't be allowed #42999

Open

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions