Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
OliverJAsh opened this issue Nov 16, 2022 · 2 comments Β· Fixed by #51502
Closed
Labels
Duplicate An existing issue was already created Fix Available A PR has been opened for this issue

Comments

@OliverJAsh
Copy link
Contributor

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.

@fatcerberus
Copy link

fatcerberus commented Nov 16, 2022

Duplicate of #51501 (NonNullable<T> is defined as T & {} so it's the same issue) and the fix is #51502

@Andarist
Copy link
Contributor

I can confirm that my PR fixes this issue. I've pushed out this repro case as an additional test case: 42ac98e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created Fix Available A PR has been opened for this issue
Projects
None yet
5 participants