Typesafe iteration over tuples and more
Helpers:
- ksxnodemodules/typescript-tuple
- totalolage/typescript-tuple
- graffhyrum/entries.md
- microsoft/TypeScript#24897 (comment)
Problem to be solved:
- Mapping (
[...].map((e, i, a) => ...)
) tuples breaks types and doesn't allow for cool type inference - fucked up
Object.keys()
,Object.values()
,Object.entries()
,Object.fromEntries()
,Array.prototype.map()
,Array.prototype.reduce()
,Array.prototype.filter()
which lose a tonn of type information partly for example because.map
accepting split parameters breaks the relation between them. Also index isnumber
which we know can be0|1|2|3|4...
.