Skip to content

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

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
iravanchi opened this issue May 1, 2015 · 1 comment
Closed

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

iravanchi opened this issue May 1, 2015 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@iravanchi
Copy link

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.

@danquirk danquirk added the Duplicate An existing issue was already created label May 1, 2015
@danquirk
Copy link
Member

danquirk commented May 1, 2015

See #2491

@danquirk danquirk closed this as completed May 1, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants