lazarljubenovic / jupiterate

1 stars 0 forks source link

`chunk` could be smarter about the inner `Array` in the return type #13

Closed lazarljubenovic closed 1 year ago

lazarljubenovic commented 1 year ago

For chunkSize values known at compile-time, we we could return an union of tuples instead of a generic Array<T>. For example, chunk(3) should return Operator<T, [T] | [T, T] | [T, T, T]>.

Unfortunately, it's not possible to mark only the last item of the iterable with a different type, and I don't think TypeScript will add such a feature in the foreseeable future.