-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flow][ref-as-prop] Allow arbitrary ref prop in component type annota…
…tion Summary: In this diff, we make further progress towards full ref-as-prop support. We will now allow the ref prop in the component type annotation to have arbitrary types, while the ref prop for component declarations are still validated to be a subtype of `React.RefSetter`. This is important to allow the following code to not error: ``` declare function HOC<R>(C: component(ref?: R)): component(ref?: R); declare component ComponentNoRefProp(); HOC(ComponentNoRefProp) // return type is component(ref?: empty) ``` Previously, the code above is often in the form of ``` declare function HOC<I>(C: component(ref?: React.RefSetter<I>)): component(ref?: React.RefSetter<I>); declare component ComponentNoRefProp(); HOC(ComponentNoRefProp) // return type is component(ref?: React.RefSetter<void>) ``` which is a leftover of the world filled with `React.AbstractComponent`. We want to get rid of these `React.RefSetter<void>` which really should be `empty` to indicate the absence of the ref prop. Changelog: [fix] In component type annotation, the ref prop can now have any type. Reviewed By: jbrown215 Differential Revision: D70508002 fbshipit-source-id: f9d3e9db7503a913e1c56305a6a1c47d9825bfcf
- Loading branch information
1 parent
f122db3
commit e944391
Showing
11 changed files
with
37 additions
and
128 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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