Reopened #6602 which has more info.
Reopened #6602 which has more info.
They are not different, Flow types are Flow types. It's really obvious that it should be in the Flow lib since the question is for an official JS function (the linked issue even links to the standard — well, to the proposal, it isn't in https://tc39.github.io/ecma262/ yet, it still is stage 3). The linked issue has a suggestion how to actually do it (better than any I'd say?):
declare export function flatten<T, X>(array?: ?Array<Array<T> | X>): Array<T | X>;
Anyway, I only linked it for those suggestions, they can be used as-is exactly, and yes I mean putting them into the Flow lib definitions.
PS: For a long moment I confused this with the far, far more onerous Flow type for extracting function arguments which covers almost ten lines of Flow definition for one thing.... but if the above line does not work for everybody that's probably the route for flatMap too, describing several levels and concatenating them with &
See #6948 for an attempt at this.
anyone progress on flat?
as a workaroung im using identity function as mapper in flatMap
const nums: Array<number> = [[1], [2], [3]].flatMap(x =>x);
I added support for common patterns (that are possible to type) for .flat:
Most helpful comment
as a workaroung im using identity function as mapper in flatMap