Skip to content

4.9 regression with in operator: object is incorrectly narrowed to neverΒ #50954

@OliverJAsh

Description

@OliverJAsh

Bug Report

πŸ”Ž Search Terms

πŸ•— Version & Regression Information

  • This changed between versions 4.8 and 4.9

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

export const checkIsTouchDevice = () =>
    "ontouchstart" in window ||
    "msMaxTouchPoints" in
        // ❌ Unexpected TS error: Property 'navigator' does not exist on type 'never'
        window.navigator;

I've reduced it down to this:

declare const obj: { a: unknown; b: unknown };

"a" in obj ||
    "prop" in
        // ❌ Unexpected TS error: Property 'b' does not exist on type 'never'
        obj.b;

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions