Skip to content

Index which's key's type is number can accept string keys #21179

Closed
@Lcng

Description

@Lcng

When I declare an index like this:
let index: {[index: number]: string} = {};
Then I can add a member to the index like this:
index['3s'] = 3;
The type of the key '3s' is string. But this works. Is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions