Closed as not planned
Description
π Search Terms
"never", "indexed access", "destruct", "property access"
π Version & Regression Information
This is the behavior in every version I tried, and I reviewed the FAQ for entries
β― Playground Link
π» Code
// Given an `example` variable of type `never`:
const example: never = null as never
// this errors correctly
// @ts-expect-error Property 'foo' does not exist on type 'never'.(2339)
example.foo
// expecting the same error here, but there is none
// @ts-expect-error Property 'foo' does not exist on type 'never'.(2339)
example['foo']
// I'd also expect the same error here, but there is none
// @ts-expect-error Property 'foo' does not exist on type 'never'.(2339)
const { foo } = example
π Actual behavior
There is an error on the property access (OK), but no error on the indexed access (NOK) and also no error when destructing (NOK)
π Expected behavior
I'd expect the same error in all three cases
Additional information about the issue
Had a discussion with @Andarist about this on twitter: