Skip to content

Commit

Permalink
nav: Simplify types on navigation props.
Browse files Browse the repository at this point in the history
This form is shorter, and also I think closer to the truth.

On the other hand, as the fixmes show, these types actually cause
the type-checker to give errors when we use these components in
`AppNavigator`!  In fact we'd need fixmes on more of them... if the
react-redux libdef didn't defeat type-checking at `connect` calls.

I think two things are going on in the fixmes:
 * The react-navigation libdef doesn't have the right covariance:
   it ends up wanting us to put more properties into the argument
   to NavigationScreenProp.
 * The libdef doesn't want to guarantee that anything in particular
   goes into `params` -- in which it is entirely correct!  That is
   an unchecked assumption we make, coupling `navActions` with the
   respective screen components.
  • Loading branch information
gnprice committed Apr 4, 2019
1 parent a4b621c commit a36814e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 29 deletions.
8 changes: 1 addition & 7 deletions src/chat/ChatScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@ import Chat from '../chat/Chat';
import ChatNavBar from '../nav/ChatNavBar';

type Props = {|
navigation: NavigationScreenProp<*> & {
state: {
params: {
narrow: Narrow,
},
},
},
navigation: NavigationScreenProp<{ params: {| narrow: Narrow |} }>,
|};

const styles = StyleSheet.create({
Expand Down
8 changes: 1 addition & 7 deletions src/emoji/EmojiPickerScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ type Props = {|
activeImageEmojiByName: RealmEmojiById,
auth: Auth,
dispatch: Dispatch,
navigation: NavigationScreenProp<*> & {
state: {
params: {
messageId: number,
},
},
},
navigation: NavigationScreenProp<{ params: {| messageId: number |} }>,
|};

type State = {|
Expand Down
9 changes: 1 addition & 8 deletions src/lightbox/LightboxScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ const styles = StyleSheet.create({
});

type Props = {|
navigation: NavigationScreenProp<*> & {
state: {
params: {
src: string,
message: Message,
},
},
},
navigation: NavigationScreenProp<{ params: {| src: string, message: Message |} }>,
|};

export default class LightboxScreen extends PureComponent<Props> {
Expand Down
2 changes: 2 additions & 0 deletions src/nav/AppNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default StackNavigator(
'account-details': { screen: AccountDetailsScreen },
'group-details': { screen: GroupDetailsScreen },
auth: { screen: AuthScreen },
// $FlowFixMe react-navigation types :-/
chat: { screen: ChatScreen },
dev: { screen: DevAuthScreen },
'emoji-picker': { screen: EmojiPickerScreen },
Expand All @@ -53,6 +54,7 @@ export default StackNavigator(
users: { screen: UsersScreen },
settings: { screen: SettingsScreen },
language: { screen: LanguageScreen },
// $FlowFixMe react-navigation types :-/
lightbox: { screen: LightboxScreen },
group: { screen: CreateGroupScreen },
'invite-users': { screen: InviteUsersScreen },
Expand Down
8 changes: 1 addition & 7 deletions src/start/AuthScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ import { loginSuccess, navigateToDev, navigateToPassword } from '../actions';
type Props = {|
dispatch: Dispatch,
realm: string,
navigation: NavigationScreenProp<*> & {
state: {
params: {
serverSettings: ApiResponseServerSettings,
},
},
},
navigation: NavigationScreenProp<{ params: {| serverSettings: ApiResponseServerSettings |} }>,
|};

let otp = '';
Expand Down

0 comments on commit a36814e

Please sign in to comment.