Skip to content

for..in object type keysΒ #48745

@blaumeise20

Description

@blaumeise20

Bug Report

πŸ”Ž Search Terms

for..in object

πŸ•— Version & Regression Information

  • I think it always was like that

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

const obj = {
    key1: "hello",
    key2: 124,
};

for (const key in obj) {
    console.log(obj[key]);
}

πŸ™ Actual behavior

There is an error "Element is implicitly 'any' because ... cannot be indexed with type 'string'".
key is of type string.

πŸ™‚ Expected behavior

It should work, and key should be "key1" | "key2".

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions