Commit 49c7eef
committed
@react-navigation/stack libdef: Simplify
As it says in the comment, Flow has some trouble with the more
complex type in types-first mode. It would give some wrong-looking
errors:
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/@react-navigation/stack_v5.x.x.js:844:22
object type [1] is incompatible with undefined [2] in the first argument. [incompatible-type]
flow-typed/@react-navigation/stack_v5.x.x.js
[2] 420│ declare type $IsUndefined<X> = $IsA<X, void>;
:
841│ +setOptions: (options: $Shape<ScreenOptions>) => void,
842│ +setParams: (
843│ params: $If<
844│ $IsUndefined<$ElementType<ParamList, RouteName>>,
845│ empty,
846│ $Shape<$NonMaybeType<$ElementType<ParamList, RouteName>>>,
847│ >,
src/nav/AppNavigator.js
[1] 53│ chat: RouteParamsOf<typeof ChatScreen>,
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ src/chat/ChatScreen.js:113:57
Cannot call navigation.setParams with object literal bound to params because object literal [1] is incompatible with
empty [2]. [incompatible-call]
src/chat/ChatScreen.js
110│
111│ const { narrow, editMessage } = route.params;
112│ const setEditMessage = useCallback(
[1] 113│ (value: EditMessage | null) => navigation.setParams({ editMessage: value }),
114│ [navigation],
115│ );
116│
flow-typed/@react-navigation/stack_v5.x.x.js
[2] 843│ params: $If<
844│ $IsUndefined<$ElementType<ParamList, RouteName>>,
845│ empty,
846│ $Shape<$NonMaybeType<$ElementType<ParamList, RouteName>>>,
847│ >,setParams a bit.1 parent 6992939 commit 49c7eef
File tree
1 file changed
+9
-5
lines changed1 file changed
+9
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
840 | 840 | | |
841 | 841 | | |
842 | 842 | | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
847 | | - | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
848 | 852 | | |
849 | 853 | | |
850 | 854 | | |
| |||
0 commit comments