Skip to content

4.9 regression: unexpected error using in operator on generic object intersected with {}Β #51549

@OliverJAsh

Description

@OliverJAsh

Bug Report

πŸ”Ž Search Terms

  • in operator
  • generic
  • object

πŸ•— Version & Regression Information

  • This changed between versions 4.8 and 4.9

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

const f = <P extends object>(a: P & {}) => {
    // Unexpected error:
    // Type 'P & {}' may represent a primitive value, which is not permitted as the right operand of the 'in' operator.ts(2638)
    "foo" in a;
};

πŸ™ Actual behavior

See code comment above.

πŸ™‚ Expected behavior

See code comment above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already createdFix AvailableA PR has been opened for this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions