-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
flat/flatMap not available #7397
Comments
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
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 |
See #6948 for an attempt at this. |
Summary: <!-- If this is a change to library defintions, please include links to relevant documentation. If this is a documentation change, please prefix the title with [DOCS]. If this is neither, ensure you opened a discussion issue and link it in the PR description. --> Fixes part of #7397 Pull Request resolved: #7854 Reviewed By: dsainati1 Differential Revision: D16091488 Pulled By: nmote fbshipit-source-id: 72af9dd2d13f604cae58135e0869712f2b20abfe
anyone progress on |
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 |
This doesn't seem to deal with arrays of different levels of nesting https://flow.org/try/#0MYewdgzgLgBGCuBbCAuGBBATpghgTwB4FEAjAU0wD4YBeGAbXoEYBdAGgYCZ2GBmHgCwsAdADMANjigAKAJQBuIA That seems like a bit of a major issue to me since a key use case of .flat() is to take input with some varied level of array nesting and flatten it out so all elements are consistent. It's the very first example given in the MDN entry https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat |
There is currently no open issue describing the lack of
flatMap
.As this is a stage 3 proposal, it should be supported by Flow.
The text was updated successfully, but these errors were encountered: