-
-
Notifications
You must be signed in to change notification settings - Fork 653
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
connect [nfc]: Work around Flow bug by making types more explicit.
Flow was determining that these components produced with `connect` had type `ComponentType<empty>`, which you can see by hovering over them in the editor wherever they're imported and used. That means that absolutely any set of props was acceptable to pass to them, which is unsound. This affected `connect` calls with a two-argument `mapStateToProps`. This is certainly a bug in Flow, because it's possible to work around it in a way that doesn't give Flow any information it didn't already have: const X = connect(/* ... */); // the exact same expression as before // $FlowFixMe const y = () => <X />; export default X; This causes, for example, `AccountDetails` to have the beautifully specific type `ComponentType<{| +user: User |}>`, instead of the unsound `ComponentType<empty>`. Fortunately, it's also possible to work around in this other way, which adds almost no net boilerplate. Do that. Change prepared mechanically, like so: $ perl -i -0pe ' s/connect(.*?): SelectorProps/connect<SelectorProps, _, _>$1/g ' src/**/*.js Fixes: #3768 Debugged-by: Chris Bobbe <cbobbe@zulipchat.com> Debugged-by: Ray Kraesig <rkraesig@zulipchat.com>
- Loading branch information
1 parent
00d64e4
commit fcde700
Showing
12 changed files
with
12 additions
and
12 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
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