FlowLib: Add typed Set wrapper (#1940)#1940
Open
avp wants to merge 17 commits intofacebook:static_hfrom
Open
Conversation
avp
added a commit
to avp/hermes
that referenced
this pull request
Mar 17, 2026
Summary: Pull Request resolved: facebook#1940 Add a generic `Set<T>` to FlowLib that wraps the native Set with typed add/has/delete/clear/forEach methods, allowing typed code to use Set methods directly. Differential Revision: D96520014
avp
added a commit
to avp/hermes
that referenced
this pull request
Mar 17, 2026
Summary: Pull Request resolved: facebook#1940 Add a generic `Set<T>` to FlowLib that wraps the native Set with typed add/has/delete/clear/forEach methods, allowing typed code to use Set methods directly. Differential Revision: D96520014
avp
added a commit
to avp/hermes
that referenced
this pull request
Mar 18, 2026
Summary: Pull Request resolved: facebook#1940 Add a generic `Set<T>` to FlowLib that wraps the native Set with typed add/has/delete/clear/forEach methods, allowing typed code to use Set methods directly. Differential Revision: D96520014
avp
added a commit
to avp/hermes
that referenced
this pull request
Mar 23, 2026
Summary: Pull Request resolved: facebook#1940 Add a generic `Set<T>` to FlowLib that wraps the native Set with typed add/has/delete/clear/forEach methods, allowing typed code to use Set methods directly. Differential Revision: D96520014
avp
added a commit
to avp/hermes
that referenced
this pull request
Mar 31, 2026
Summary: Pull Request resolved: facebook#1940 Add a generic `Set<T>` to FlowLib that wraps the native Set with typed add/has/delete/clear/forEach methods, allowing typed code to use Set methods directly. Differential Revision: D96520014
avp
added a commit
to avp/hermes
that referenced
this pull request
Mar 31, 2026
Summary: Pull Request resolved: facebook#1940 Add a generic `Set<T>` to FlowLib that wraps the native Set with typed add/has/delete/clear/forEach methods, allowing typed code to use Set methods directly. Differential Revision: D96520014
avp
added a commit
to avp/hermes
that referenced
this pull request
Apr 8, 2026
Summary: Pull Request resolved: facebook#1940 Add a generic `Set<T>` to FlowLib that wraps the native Set with typed add/has/delete/clear/forEach methods, allowing typed code to use Set methods directly. Differential Revision: D96520014
Summary: We can infer more parameters if we first go over simple formal parameters (e.g. `t: T`) and just infer those. Then we can infer the types of callbacks even if their types require going left to right. We're not doing any arbitrary ordering, just applying a simple heuristic to significantly improve the power of our rudimentary generic type inference. Differential Revision: D100083710
Summary:
We need to allow functions that take fewer parameters to flow into
functions that take more.
```
function foo(cb: number=>void) { cb(1) }
foo( () => {} )
```
is valid Flow and this pattern is quite common in FlowLib.
`cb` need not have only optional parameters.
We also update the type inference matching to allow for non-optional
parameters to get matched (to avoid regressing inference flexibility).
Differential Revision: D100701965
Summary: This can be implemented without compromising inference now. Differential Revision: D100083709
Summary: Add indexOf and lastIndexOf methods to the typed Array class in FlowLib. Both take a single searchElement argument and perform linear search forward/backward respectively. Differential Revision: D98024443
Summary: Add the at() method to the typed Array class in FlowLib. Supports negative indexing and returns T | void for out-of-bounds access. Differential Revision: D98024448
Summary: Add every() and some() predicate methods to the typed Array class in FlowLib. Both mirror the forEach pattern with boolean callbacks. Differential Revision: D98024449
Summary: Add find() and findIndex() methods to the typed Array class in FlowLib. find() returns T | void, findIndex() returns number (-1 if not found). Both use the standard callback pattern. Differential Revision: D98024445
Summary: Add findLast() and findLastIndex() methods to the typed Array class in FlowLib. These are the reverse-iteration counterparts of find() and findIndex(). Differential Revision: D98024441
Summary: Add the join() method to the typed Array class in FlowLib. Takes a separator string argument and concatenates all elements. Similar to toString() but with a configurable separator. Differential Revision: D98024440
Summary: Add the slice() method to the typed Array class in FlowLib. Takes start and end indices (both required) with negative index support. Returns a new array containing the selected elements. Differential Revision: D98024439
Summary: Add the toReversed() method to the typed Array class in FlowLib. Returns a new array with elements in reverse order without modifying the original. Differential Revision: D98024452
Summary: Add the with() method to the typed Array class in FlowLib. Returns a new array with the element at the given index replaced by the provided value. Supports negative indexing. Differential Revision: D98024442
Summary: Add the fill() method to the typed Array class in FlowLib. This is a mutating method that sets all elements to the given value and returns the array. Takes only the value argument (no start/end range since optional params are not supported). Differential Revision: D98024446
Summary: Add the reverse() method to the typed Array class in FlowLib. This is a mutating in-place swap and returns the array. Differential Revision: D98024447
Summary: Add the copyWithin() method to the typed Array class in FlowLib. Handles overlapping copies by copying backward when target > start. Takes target, start, and end indices (all required) with negative index support. Also add TODO comments for pop/shift which cannot be implemented because assigning this.length is not supported in FlowLib. Differential Revision: D98024444
Summary: Add a generic `Map<K, V>` to FlowLib that wraps the native Map with typed methods, allowing typed code to use map.get()/map.set() directly instead of using hacks. Update the widgets benchmark and test to use the new typed Map. Removing the mapPrototypeGet/mapPrototypeSet hacks and use proper generic types. Differential Revision: D96520015
Summary: Pull Request resolved: facebook#1940 Add a generic `Set<T>` to FlowLib that wraps the native Set with typed add/has/delete/clear/forEach methods, allowing typed code to use Set methods directly. Reviewed By: micleo2 Differential Revision: D96520014
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Add a generic
Set<T>to FlowLib that wraps the native Setwith typed add/has/delete/clear/forEach methods, allowing
typed code to use Set methods directly.
Reviewed By: micleo2
Differential Revision: D96520014