2

Closed

decaring types for array-based tuples

description

Many JavaScript libraries have a way of returning tuples of data, in the form of 2-element arrays.

For example, some iterators (like Lazy.js) or stream libraries (like Highland) can iterate over an object's properties and will emit a sequence of 2 -element arrays: with the first element of each tuple being the property name, and the second one the actual value.

So when iterating a Dict object that maps strings to numbers it yields this:
[['keyA', 123], ['keyB', 456], ['keyC', 789]]
This would also be relevant when iterating ES6 Map's through a stream wrapper:
[[objA, decorationA], [objB, decorationB], [objC, decorationC]]
Maybe this could in some way mesh with the indexer declaration feature? It seems conceptually closely related.

Like:
interface MapTuple<K, V> {
    [0]: K;
    [1]: V;
}
Closed Jul 28, 2014 at 11:17 PM by jonturner
As part of our move to GitHub, we're closing our CodePlex suggestions and asking that people move them to the GitHub issue tracker for further discussion. Some feature requests may already be active on GitHub, so please make sure to look for an existing issue before filing a new one.

You can find our GitHub issue tracker here:
https://github.com/microsoft/typeScript/issues

comments