Skip to content

object type does not work with in operator #14269

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

Closed
EliSnow opened this issue Feb 23, 2017 · 1 comment · Fixed by #14467
Closed

object type does not work with in operator #14269

EliSnow opened this issue Feb 23, 2017 · 1 comment · Fixed by #14467
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@EliSnow
Copy link

EliSnow commented Feb 23, 2017

TypeScript Version: 2.2.1

Code

const b = "foo" in <object> {};

Expected behavior:
The in operator works

Actual behavior:
A compile error is provided:
The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter

@axefrog
Copy link

axefrog commented Mar 30, 2017

Just experienced the same issue:

export function isIterable<T>(value: object): value is Iterable<T> {
  return Symbol.iterator in value;
}

image

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Mar 30, 2017
@DanielRosenwasser DanielRosenwasser added the Fixed A PR has been merged for this issue label Mar 31, 2017
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 2.3.1 milestone Mar 31, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
5 participants