In converting flow code to typescript an error happens when using iterators. The iterator is missing something
const iter: Iterator<RouteData> = contentMap.routes();
const contentArray: Array<RouteData> = Array.from(iter);
It gives the following error, notice that this points to the second line, so iter is of correct type/the return of contentMap.routes() is an iterator:
Error:(109, 55) TS2769: No overload matches this call.
Overload 1 of 4, '(iterable: Iterable<RouteData> | ArrayLike<RouteData>): RouteData[]', gave the following error.
Argument of type 'Iterator<RouteData, any, undefined>' is not assignable to parameter of type 'Iterable<RouteData> | ArrayLike<RouteData>'.
Property 'length' is missing in type 'Iterator<RouteData, any, undefined>' but required in type 'ArrayLike<RouteData>'.
Overload 2 of 4, '(arrayLike: ArrayLike<RouteData>): RouteData[]', gave the following error.
Argument of type 'Iterator<RouteData, any, undefined>' is not assignable to parameter of type 'ArrayLike<RouteData>'.
Why does this happen, and how do I fix it?
The iterator is created somewhere like:
routes():Iterator<RouteData> {
return this._routes.values();
}
The compile target for typescript is "es6", so maps should be fully supported? Or is it just impossible to create an array from an iterator and have I been doing it all wrong (and was babel just that forgiving)?