Skip to content

Allow enum types to be index parameters in array interfaces #2992

Closed
@iravanchi

Description

@iravanchi

We can do this:

memberName: { [index: number]: string };

And then use enums as index signature parameters, since they are some kind of numbers:

this.memberName[EnumType.EnumMember] = "";

But the language does not allow defining the index signature parameters to be an enum type, like this:

memberName: { [index: EnumType]: string };

Which can be used the same way, and the compiler can check that the references are all using the EnumType, not an arbitrary number.

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