Skip to content

for ... in obj where obj: object gives TS2407 #14187

@mattpap

Description

@mattpap

TypeScript Version: 2.2.0

$ node_modules/.bin/tsc --version
Version 2.2.0

Code

let obj: object = {}

for (const attr in obj) {
  const val = obj[attr]
}

Expected behavior:

Compiles without errors.

Actual behavior:

some.ts(3,20): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.

This is a new feature, so I'm not sure if I'm using this properly, but the error message says that an object type is allowed, so I expect this behavior to be a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions