Skip to content

generics in interface definition of iterable data structures. #2153

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
pmapcat opened this issue Feb 26, 2015 · 4 comments
Closed

generics in interface definition of iterable data structures. #2153

pmapcat opened this issue Feb 26, 2015 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@pmapcat
Copy link

pmapcat commented Feb 26, 2015

Example:

interface AnySet<T> {
    [index:T]:boolean
}

will output "error TS1023: An index signature parameter type must be 'string' or 'number'", which is clearly not an intended behaviour.

@mhegazy
Copy link
Contributor

mhegazy commented Feb 26, 2015

what other indexer types do you want to use?

@pmapcat
Copy link
Author

pmapcat commented Feb 26, 2015

Actually, I do not want to use other types instead of allowed string|number, but there should be a way to use them both.
Of course I may not specify type at all(using any), or dublicate every function,like

set__concat_string_indexer
set__concat_number_indexer
set__remove_string_indexer
set__remove_number_indexer
e.t.c

But in my point of view it looks quite ugly.
In addition: this is not working as well:
{ [index:number|string]:boolean}
Maybe it is not that important, but in my point of view this is the kind of good feauture.
Thank you.

@mhegazy
Copy link
Contributor

mhegazy commented Feb 26, 2015

This is referenced in #1778.

@mhegazy mhegazy added the Duplicate An existing issue was already created label Feb 26, 2015
@pmapcat pmapcat closed this as completed Feb 26, 2015
@pmapcat
Copy link
Author

pmapcat commented Feb 26, 2015

I guess I should close it then
Sorry for incovenience.

@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