diff --git a/native/chat/chat-input-bar.react.js b/native/chat/chat-input-bar.react.js --- a/native/chat/chat-input-bar.react.js +++ b/native/chat/chat-input-bar.react.js @@ -928,7 +928,7 @@ sendTime: 0, retries: 0, }; - navigation.navigate({ + navigation.navigate<'ImagePasteModal'>({ name: ImagePasteModalRouteName, params: { imagePasteStagingInfo: pastedImage, @@ -966,7 +966,7 @@ const openCamera = React.useCallback(() => { keyboardState?.dismissKeyboard(); - navigation.navigate({ + navigation.navigate<'CameraModal'>({ name: CameraModalRouteName, params: { presentedFrom: route.key, diff --git a/native/chat/chat-thread-list.react.js b/native/chat/chat-thread-list.react.js --- a/native/chat/chat-thread-list.react.js +++ b/native/chat/chat-thread-list.react.js @@ -549,7 +549,7 @@ if (this.searchInput) { this.searchInput.blur(); } - this.props.navigation.navigate({ + this.props.navigation.navigate<'SidebarListModal'>({ name: SidebarListModalRouteName, params: { threadInfo }, }); diff --git a/native/chat/compose-thread-button.react.js b/native/chat/compose-thread-button.react.js --- a/native/chat/compose-thread-button.react.js +++ b/native/chat/compose-thread-button.react.js @@ -38,7 +38,7 @@ onPress = () => { if (this.props.viewerID) { - this.props.navigate({ + this.props.navigate<'MessageList'>({ name: MessageListRouteName, params: { threadInfo: createPendingThread({ diff --git a/native/chat/message-list-header-title.react.js b/native/chat/message-list-header-title.react.js --- a/native/chat/message-list-header-title.react.js +++ b/native/chat/message-list-header-title.react.js @@ -65,7 +65,7 @@ onPress = () => { const threadInfo = this.props.threadInfo; - this.props.navigate({ + this.props.navigate<'ThreadSettings'>({ name: ThreadSettingsRouteName, params: { threadInfo }, key: `${ThreadSettingsRouteName}${threadInfo.id}`, diff --git a/native/chat/message-list-types.js b/native/chat/message-list-types.js --- a/native/chat/message-list-types.js +++ b/native/chat/message-list-types.js @@ -64,7 +64,7 @@ const { navigate } = useNavigation(); return React.useCallback( (params: MessageListParams) => { - navigate(createNavigateToThreadAction(params)); + navigate<'MessageList'>(createNavigateToThreadAction(params)); }, [navigate], ); diff --git a/native/chat/multimedia-message.react.js b/native/chat/multimedia-message.react.js --- a/native/chat/multimedia-message.react.js +++ b/native/chat/multimedia-message.react.js @@ -64,7 +64,7 @@ initialCoordinates: LayoutCoordinates, ) => { const { navigation, item, route, verticalBounds } = this.props; - navigation.navigate({ + navigation.navigate<'VideoPlaybackModal' | 'ImageModal'>({ name: mediaInfo.type === 'video' ? VideoPlaybackModalRouteName @@ -152,7 +152,7 @@ margin = aboveMargin; } - this.props.navigation.navigate({ + this.props.navigation.navigate<'MultimediaMessageTooltipModal'>({ name: MultimediaMessageTooltipModalRouteName, params: { presentedFrom: this.props.route.key, diff --git a/native/chat/robotext-message.react.js b/native/chat/robotext-message.react.js --- a/native/chat/robotext-message.react.js +++ b/native/chat/robotext-message.react.js @@ -115,7 +115,7 @@ margin = aboveMargin; } - props.navigation.navigate({ + props.navigation.navigate<'RobotextMessageTooltipModal'>({ name: RobotextMessageTooltipModalRouteName, params: { presentedFrom: props.route.key, diff --git a/native/chat/settings/compose-subchannel-modal.react.js b/native/chat/settings/compose-subchannel-modal.react.js --- a/native/chat/settings/compose-subchannel-modal.react.js +++ b/native/chat/settings/compose-subchannel-modal.react.js @@ -72,7 +72,7 @@ onPressOpen = () => { const threadInfo = this.props.route.params.threadInfo; - this.props.navigation.navigate({ + this.props.navigation.navigate<'ComposeSubchannel'>({ name: ComposeSubchannelRouteName, params: { threadType: threadTypes.COMMUNITY_OPEN_SUBTHREAD, @@ -86,7 +86,7 @@ onPressSecret = () => { const threadInfo = this.props.route.params.threadInfo; - this.props.navigation.navigate({ + this.props.navigation.navigate<'ComposeSubchannel'>({ name: ComposeSubchannelRouteName, params: { threadType: threadTypes.COMMUNITY_SECRET_SUBTHREAD, diff --git a/native/chat/settings/thread-settings-color.react.js b/native/chat/settings/thread-settings-color.react.js --- a/native/chat/settings/thread-settings-color.react.js +++ b/native/chat/settings/thread-settings-color.react.js @@ -65,7 +65,7 @@ } onPressEditColor = () => { - this.props.navigate({ + this.props.navigate<'ColorSelectorModal'>({ name: ColorSelectorModalRouteName, params: { presentedFrom: this.props.threadSettingsRouteKey, diff --git a/native/chat/settings/thread-settings-delete-thread.react.js b/native/chat/settings/thread-settings-delete-thread.react.js --- a/native/chat/settings/thread-settings-delete-thread.react.js +++ b/native/chat/settings/thread-settings-delete-thread.react.js @@ -19,7 +19,7 @@ function ThreadSettingsDeleteThread(props: Props): React.Node { const { navigate, threadInfo } = props; const onPress = React.useCallback(() => { - navigate({ + navigate<'DeleteThread'>({ name: DeleteThreadRouteName, params: { threadInfo }, key: `${DeleteThreadRouteName}${threadInfo.id}`, diff --git a/native/chat/settings/thread-settings-member.react.js b/native/chat/settings/thread-settings-member.react.js --- a/native/chat/settings/thread-settings-member.react.js +++ b/native/chat/settings/thread-settings-member.react.js @@ -181,7 +181,7 @@ editButton.measure((x, y, width, height, pageX, pageY) => { const coordinates = { x: pageX, y: pageY, width, height }; - this.props.navigate({ + this.props.navigate<'ThreadSettingsMemberTooltipModal'>({ name: ThreadSettingsMemberTooltipModalRouteName, params: { presentedFrom: this.props.threadSettingsRouteKey, diff --git a/native/chat/sidebar-navigation.js b/native/chat/sidebar-navigation.js --- a/native/chat/sidebar-navigation.js +++ b/native/chat/sidebar-navigation.js @@ -58,7 +58,9 @@ chatContext?.setCurrentTransitionSidebarSourceID( route.params.item.messageInfo.id, ); - navigation.navigate(createNavigateToThreadAction({ threadInfo })); + navigation.navigate<'MessageList'>( + createNavigateToThreadAction({ threadInfo }), + ); } function useNavigateToSidebar(item: ChatMessageInfoItemWithHeight): () => void { diff --git a/native/chat/text-message.react.js b/native/chat/text-message.react.js --- a/native/chat/text-message.react.js +++ b/native/chat/text-message.react.js @@ -179,7 +179,7 @@ margin = aboveMargin; } - this.props.navigation.navigate({ + this.props.navigation.navigate<'TextMessageTooltipModal'>({ name: TextMessageTooltipModalRouteName, params: { presentedFrom: this.props.route.key, diff --git a/native/chat/thread-settings-button.react.js b/native/chat/thread-settings-button.react.js --- a/native/chat/thread-settings-button.react.js +++ b/native/chat/thread-settings-button.react.js @@ -30,7 +30,7 @@ onPress = () => { const threadInfo = this.props.threadInfo; - this.props.navigate({ + this.props.navigate<'ThreadSettings'>({ name: ThreadSettingsRouteName, params: { threadInfo }, key: `${ThreadSettingsRouteName}${threadInfo.id}`, diff --git a/native/flow-typed/npm/@react-navigation/bottom-tabs_v5.x.x.js b/native/flow-typed/npm/@react-navigation/bottom-tabs_v5.x.x.js --- a/native/flow-typed/npm/@react-navigation/bottom-tabs_v5.x.x.js +++ b/native/flow-typed/npm/@react-navigation/bottom-tabs_v5.x.x.js @@ -450,6 +450,12 @@ declare type $Partial = $ReadOnly<$Rest>; + // If { ...T, ... } counts as a T, then we're inexact + declare type $IsExact = $Call< + (T => false) & (mixed => true), + { ...T, ... }, + >; + /** * Actions, state, etc. */ @@ -808,25 +814,45 @@ * Navigation prop */ + declare type PartialWithMergeProperty = $If< + $IsExact, + { ...$Partial, +merge: true }, + { ...$Partial, +merge: true, ... }, + >; + + declare type EitherExactOrPartialWithMergeProperty = + | ParamsType + | PartialWithMergeProperty; + declare export type SimpleNavigate = >( routeName: DestinationRouteName, - params: $ElementType, + params: EitherExactOrPartialWithMergeProperty< + $ElementType, + >, ) => void; declare export type Navigate = & SimpleNavigate & >( - route: + route: $If< + $IsUndefined<$ElementType>, + | {| +key: string |} | + {| +name: DestinationRouteName, +key?: string |}, | {| +key: string, - +params?: $ElementType, - |} - | {| + +params?: EitherExactOrPartialWithMergeProperty< + $ElementType, + >, + |} | + {| +name: DestinationRouteName, +key?: string, - +params?: $ElementType, + +params?: EitherExactOrPartialWithMergeProperty< + $ElementType, + >, |}, + >, ) => void; declare type NavigationHelpers< @@ -861,6 +887,15 @@ ... }; + declare type SetParamsInput< + ParamList: ParamListBase, + RouteName: $Keys = $Keys, + > = $If< + $IsUndefined<$ElementType>, + empty, + $Partial<$NonMaybeType<$ElementType>>, + >; + declare export type NavigationProp< ParamList: ParamListBase, RouteName: $Keys = $Keys, @@ -874,13 +909,7 @@ EventMap, >>, +setOptions: (options: $Partial) => void, - +setParams: ( - params: $If< - $IsUndefined<$ElementType>, - empty, - $Partial<$NonMaybeType<$ElementType>>, - >, - ) => void, + +setParams: (params: SetParamsInput) => void, ... }; diff --git a/native/flow-typed/npm/@react-navigation/devtools_v5.x.x.js b/native/flow-typed/npm/@react-navigation/devtools_v5.x.x.js --- a/native/flow-typed/npm/@react-navigation/devtools_v5.x.x.js +++ b/native/flow-typed/npm/@react-navigation/devtools_v5.x.x.js @@ -450,6 +450,12 @@ declare type $Partial = $ReadOnly<$Rest>; + // If { ...T, ... } counts as a T, then we're inexact + declare type $IsExact = $Call< + (T => false) & (mixed => true), + { ...T, ... }, + >; + /** * Actions, state, etc. */ @@ -808,25 +814,45 @@ * Navigation prop */ + declare type PartialWithMergeProperty = $If< + $IsExact, + { ...$Partial, +merge: true }, + { ...$Partial, +merge: true, ... }, + >; + + declare type EitherExactOrPartialWithMergeProperty = + | ParamsType + | PartialWithMergeProperty; + declare export type SimpleNavigate = >( routeName: DestinationRouteName, - params: $ElementType, + params: EitherExactOrPartialWithMergeProperty< + $ElementType, + >, ) => void; declare export type Navigate = & SimpleNavigate & >( - route: + route: $If< + $IsUndefined<$ElementType>, + | {| +key: string |} | + {| +name: DestinationRouteName, +key?: string |}, | {| +key: string, - +params?: $ElementType, - |} - | {| + +params?: EitherExactOrPartialWithMergeProperty< + $ElementType, + >, + |} | + {| +name: DestinationRouteName, +key?: string, - +params?: $ElementType, + +params?: EitherExactOrPartialWithMergeProperty< + $ElementType, + >, |}, + >, ) => void; declare type NavigationHelpers< @@ -861,6 +887,15 @@ ... }; + declare type SetParamsInput< + ParamList: ParamListBase, + RouteName: $Keys = $Keys, + > = $If< + $IsUndefined<$ElementType>, + empty, + $Partial<$NonMaybeType<$ElementType>>, + >; + declare export type NavigationProp< ParamList: ParamListBase, RouteName: $Keys = $Keys, @@ -874,13 +909,7 @@ EventMap, >>, +setOptions: (options: $Partial) => void, - +setParams: ( - params: $If< - $IsUndefined<$ElementType>, - empty, - $Partial<$NonMaybeType<$ElementType>>, - >, - ) => void, + +setParams: (params: SetParamsInput) => void, ... }; diff --git a/native/flow-typed/npm/@react-navigation/material-top-tabs_v5.x.x.js b/native/flow-typed/npm/@react-navigation/material-top-tabs_v5.x.x.js --- a/native/flow-typed/npm/@react-navigation/material-top-tabs_v5.x.x.js +++ b/native/flow-typed/npm/@react-navigation/material-top-tabs_v5.x.x.js @@ -450,6 +450,12 @@ declare type $Partial = $ReadOnly<$Rest>; + // If { ...T, ... } counts as a T, then we're inexact + declare type $IsExact = $Call< + (T => false) & (mixed => true), + { ...T, ... }, + >; + /** * Actions, state, etc. */ @@ -808,25 +814,45 @@ * Navigation prop */ + declare type PartialWithMergeProperty = $If< + $IsExact, + { ...$Partial, +merge: true }, + { ...$Partial, +merge: true, ... }, + >; + + declare type EitherExactOrPartialWithMergeProperty = + | ParamsType + | PartialWithMergeProperty; + declare export type SimpleNavigate = >( routeName: DestinationRouteName, - params: $ElementType, + params: EitherExactOrPartialWithMergeProperty< + $ElementType, + >, ) => void; declare export type Navigate = & SimpleNavigate & >( - route: + route: $If< + $IsUndefined<$ElementType>, + | {| +key: string |} | + {| +name: DestinationRouteName, +key?: string |}, | {| +key: string, - +params?: $ElementType, - |} - | {| + +params?: EitherExactOrPartialWithMergeProperty< + $ElementType, + >, + |} | + {| +name: DestinationRouteName, +key?: string, - +params?: $ElementType, + +params?: EitherExactOrPartialWithMergeProperty< + $ElementType, + >, |}, + >, ) => void; declare type NavigationHelpers< @@ -861,6 +887,15 @@ ... }; + declare type SetParamsInput< + ParamList: ParamListBase, + RouteName: $Keys = $Keys, + > = $If< + $IsUndefined<$ElementType>, + empty, + $Partial<$NonMaybeType<$ElementType>>, + >; + declare export type NavigationProp< ParamList: ParamListBase, RouteName: $Keys = $Keys, @@ -874,13 +909,7 @@ EventMap, >>, +setOptions: (options: $Partial) => void, - +setParams: ( - params: $If< - $IsUndefined<$ElementType>, - empty, - $Partial<$NonMaybeType<$ElementType>>, - >, - ) => void, + +setParams: (params: SetParamsInput) => void, ... }; diff --git a/native/flow-typed/npm/@react-navigation/native_v5.x.x.js b/native/flow-typed/npm/@react-navigation/native_v5.x.x.js --- a/native/flow-typed/npm/@react-navigation/native_v5.x.x.js +++ b/native/flow-typed/npm/@react-navigation/native_v5.x.x.js @@ -450,6 +450,12 @@ declare type $Partial = $ReadOnly<$Rest>; + // If { ...T, ... } counts as a T, then we're inexact + declare type $IsExact = $Call< + (T => false) & (mixed => true), + { ...T, ... }, + >; + /** * Actions, state, etc. */ @@ -808,25 +814,45 @@ * Navigation prop */ + declare type PartialWithMergeProperty = $If< + $IsExact, + { ...$Partial, +merge: true }, + { ...$Partial, +merge: true, ... }, + >; + + declare type EitherExactOrPartialWithMergeProperty = + | ParamsType + | PartialWithMergeProperty; + declare export type SimpleNavigate = >( routeName: DestinationRouteName, - params: $ElementType, + params: EitherExactOrPartialWithMergeProperty< + $ElementType, + >, ) => void; declare export type Navigate = & SimpleNavigate & >( - route: + route: $If< + $IsUndefined<$ElementType>, + | {| +key: string |} | + {| +name: DestinationRouteName, +key?: string |}, | {| +key: string, - +params?: $ElementType, - |} - | {| + +params?: EitherExactOrPartialWithMergeProperty< + $ElementType, + >, + |} | + {| +name: DestinationRouteName, +key?: string, - +params?: $ElementType, + +params?: EitherExactOrPartialWithMergeProperty< + $ElementType, + >, |}, + >, ) => void; declare type NavigationHelpers< @@ -861,6 +887,15 @@ ... }; + declare type SetParamsInput< + ParamList: ParamListBase, + RouteName: $Keys = $Keys, + > = $If< + $IsUndefined<$ElementType>, + empty, + $Partial<$NonMaybeType<$ElementType>>, + >; + declare export type NavigationProp< ParamList: ParamListBase, RouteName: $Keys = $Keys, @@ -874,13 +909,7 @@ EventMap, >>, +setOptions: (options: $Partial) => void, - +setParams: ( - params: $If< - $IsUndefined<$ElementType>, - empty, - $Partial<$NonMaybeType<$ElementType>>, - >, - ) => void, + +setParams: (params: SetParamsInput) => void, ... }; diff --git a/native/flow-typed/npm/@react-navigation/stack_v5.x.x.js b/native/flow-typed/npm/@react-navigation/stack_v5.x.x.js --- a/native/flow-typed/npm/@react-navigation/stack_v5.x.x.js +++ b/native/flow-typed/npm/@react-navigation/stack_v5.x.x.js @@ -450,6 +450,12 @@ declare type $Partial = $ReadOnly<$Rest>; + // If { ...T, ... } counts as a T, then we're inexact + declare type $IsExact = $Call< + (T => false) & (mixed => true), + { ...T, ... }, + >; + /** * Actions, state, etc. */ @@ -808,25 +814,45 @@ * Navigation prop */ + declare type PartialWithMergeProperty = $If< + $IsExact, + { ...$Partial, +merge: true }, + { ...$Partial, +merge: true, ... }, + >; + + declare type EitherExactOrPartialWithMergeProperty = + | ParamsType + | PartialWithMergeProperty; + declare export type SimpleNavigate = >( routeName: DestinationRouteName, - params: $ElementType, + params: EitherExactOrPartialWithMergeProperty< + $ElementType, + >, ) => void; declare export type Navigate = & SimpleNavigate & >( - route: + route: $If< + $IsUndefined<$ElementType>, + | {| +key: string |} | + {| +name: DestinationRouteName, +key?: string |}, | {| +key: string, - +params?: $ElementType, - |} - | {| + +params?: EitherExactOrPartialWithMergeProperty< + $ElementType, + >, + |} | + {| +name: DestinationRouteName, +key?: string, - +params?: $ElementType, + +params?: EitherExactOrPartialWithMergeProperty< + $ElementType, + >, |}, + >, ) => void; declare type NavigationHelpers< @@ -861,6 +887,15 @@ ... }; + declare type SetParamsInput< + ParamList: ParamListBase, + RouteName: $Keys = $Keys, + > = $If< + $IsUndefined<$ElementType>, + empty, + $Partial<$NonMaybeType<$ElementType>>, + >; + declare export type NavigationProp< ParamList: ParamListBase, RouteName: $Keys = $Keys, @@ -874,13 +909,7 @@ EventMap, >>, +setOptions: (options: $Partial) => void, - +setParams: ( - params: $If< - $IsUndefined<$ElementType>, - empty, - $Partial<$NonMaybeType<$ElementType>>, - >, - ) => void, + +setParams: (params: SetParamsInput) => void, ... }; diff --git a/native/profile/relationship-list-item.react.js b/native/profile/relationship-list-item.react.js --- a/native/profile/relationship-list-item.react.js +++ b/native/profile/relationship-list-item.react.js @@ -221,7 +221,7 @@ }; editButton.current.measure((x, y, width, height, pageX, pageY) => { const coordinates = { x: pageX, y: pageY, width, height }; - this.props.navigate({ + this.props.navigate<'RelationshipListItemTooltipModal'>({ name: RelationshipListItemTooltipModalRouteName, params: { presentedFrom: this.props.relationshipListRoute.key,