diff --git a/src/common/RawLabel.js b/src/common/RawLabel.js index 8b76d783970..0fb92de4963 100644 --- a/src/common/RawLabel.js +++ b/src/common/RawLabel.js @@ -1,6 +1,7 @@ /* @flow strict-local */ import invariant from 'invariant'; import React, { PureComponent } from 'react'; +import type { Node, Context } from 'react'; import { Text } from 'react-native'; import type { ThemeData } from '../styles'; @@ -24,10 +25,10 @@ type Props = $ReadOnly<{| * See upstream: https://reactnative.dev/docs/text */ export default class RawLabel extends PureComponent { - static contextType = ThemeContext; + static contextType: Context = ThemeContext; context: ThemeData; - render() { + render(): Node { const { text, children, style, ...restProps } = this.props; invariant((text != null) !== (children != null), 'pass either `text` or `children`'); diff --git a/src/common/SectionHeader.js b/src/common/SectionHeader.js index a07ec50254b..3313fd1d117 100644 --- a/src/common/SectionHeader.js +++ b/src/common/SectionHeader.js @@ -1,5 +1,6 @@ /* @flow strict-local */ import React, { PureComponent } from 'react'; +import type { Node, Context } from 'react'; import { View } from 'react-native'; import type { ThemeData } from '../styles'; @@ -18,10 +19,10 @@ type Props = $ReadOnly<{| |}>; export default class SectionHeader extends PureComponent { - static contextType = ThemeContext; + static contextType: Context = ThemeContext; context: ThemeData; - render() { + render(): Node { const { text } = this.props; return ( diff --git a/src/nav/BackNavigationHandler.js b/src/nav/BackNavigationHandler.js index c689acca73e..c52417182cd 100644 --- a/src/nav/BackNavigationHandler.js +++ b/src/nav/BackNavigationHandler.js @@ -19,7 +19,7 @@ export default class BackNavigationHandler extends PureComponent { BackHandler.removeEventListener('hardwareBackPress', this.handleBackButtonPress); } - handleBackButtonPress = () => { + handleBackButtonPress: () => boolean = () => { const canGoBack = NavigationService.getState().index > 0; if (canGoBack) { NavigationService.dispatch( @@ -32,7 +32,7 @@ export default class BackNavigationHandler extends PureComponent { return canGoBack; }; - render() { + render(): Node { return this.props.children; } } diff --git a/src/nav/NavButton.js b/src/nav/NavButton.js index a83d6120d3d..7a04357fc0e 100644 --- a/src/nav/NavButton.js +++ b/src/nav/NavButton.js @@ -1,5 +1,6 @@ /* @flow strict-local */ import React from 'react'; +import type { Node } from 'react'; import type { TextStyleProp } from 'react-native/Libraries/StyleSheet/StyleSheet'; import { BRAND_COLOR, createStyleSheet } from '../styles'; @@ -21,7 +22,7 @@ const componentStyles = createStyleSheet({ }, }); -export default function NavButton(props: Props) { +export default function NavButton(props: Props): Node { const { name, style, color = BRAND_COLOR, onPress, accessibilityLabel } = props; return ( diff --git a/src/settings/LanguagePicker.js b/src/settings/LanguagePicker.js index 43f0bed4ae5..727717ef45a 100644 --- a/src/settings/LanguagePicker.js +++ b/src/settings/LanguagePicker.js @@ -1,5 +1,6 @@ /* @flow strict-local */ import React, { PureComponent } from 'react'; +import type { Node, Context } from 'react'; import { FlatList } from 'react-native'; import type { GetText } from '../types'; @@ -15,10 +16,10 @@ type Props = $ReadOnly<{| |}>; export default class LanguagePicker extends PureComponent { - static contextType = TranslationContext; + static contextType: Context = TranslationContext; context: GetText; - getTranslatedLanguages = (): Language[] => + getTranslatedLanguages: () => Language[] = () => languages.map((language: Language) => { const _ = this.context; const translatedName = _(language.name); @@ -28,7 +29,7 @@ export default class LanguagePicker extends PureComponent { }; }); - getFilteredLanguageList = (filter: string): Language[] => { + getFilteredLanguageList: string => Language[] = filter => { const list = this.getTranslatedLanguages(); if (!filter) { @@ -43,7 +44,7 @@ export default class LanguagePicker extends PureComponent { }); }; - render() { + render(): Node { const { value, onValueChange, filter } = this.props; const data = this.getFilteredLanguageList(filter); diff --git a/src/sharing/ShareToPm.js b/src/sharing/ShareToPm.js index 07d1ffcee60..b5d73664578 100644 --- a/src/sharing/ShareToPm.js +++ b/src/sharing/ShareToPm.js @@ -1,5 +1,6 @@ /* @flow strict-local */ import React from 'react'; +import type { Node, Context } from 'react'; import { View, Modal } from 'react-native'; import type { RouteProp } from '../react-navigation'; @@ -36,24 +37,24 @@ type State = $ReadOnly<{| |}>; export default class ShareToPm extends React.Component { - static contextType = TranslationContext; + static contextType: Context = TranslationContext; context: GetText; - state = { + state: State = { selectedRecipients: [], choosingRecipients: false, }; - handleModalClose = () => { + handleModalClose: () => void = () => { this.setState({ choosingRecipients: false }); }; - handleChooseRecipients = (selectedRecipients: $ReadOnlyArray) => { + handleChooseRecipients: ($ReadOnlyArray) => void = selectedRecipients => { this.setState({ selectedRecipients }); this.setState({ choosingRecipients: false }); }; - isSendButtonEnabled = (message: string) => { + isSendButtonEnabled: string => boolean = message => { const { selectedRecipients } = this.state; const { sharedData } = this.props.route.params; @@ -64,7 +65,7 @@ export default class ShareToPm extends React.Component { return selectedRecipients.length > 0; }; - renderUsersPreview = () => { + renderUsersPreview: () => Node = () => { const { selectedRecipients } = this.state; if (selectedRecipients.length === 0) { @@ -77,7 +78,7 @@ export default class ShareToPm extends React.Component { return preview; }; - render() { + render(): Node { const { selectedRecipients, choosingRecipients } = this.state; const { sharedData } = this.props.route.params; const sendTo = { selectedRecipients, type: 'pm' }; diff --git a/src/start/CompatibilityScreen.js b/src/start/CompatibilityScreen.js index 8395e1ade00..cd5c5f79504 100644 --- a/src/start/CompatibilityScreen.js +++ b/src/start/CompatibilityScreen.js @@ -1,5 +1,6 @@ /* @flow strict-local */ import React, { PureComponent } from 'react'; +import type { Node } from 'react'; import { Image, Text, View, Platform } from 'react-native'; import { openLinkExternal } from '../utils/openLink'; @@ -46,16 +47,16 @@ const GooglePlayBadge = () => ( ); export default class CompatibilityScreen extends PureComponent<{||}> { - storeURL = + storeURL: string = Platform.OS === 'ios' ? 'https://itunes.apple.com/app/zulip/id1203036395' : 'https://play.google.com/store/apps/details?id=com.zulipmobile'; - openStoreURL = () => { + openStoreURL: () => void = () => { openLinkExternal(this.storeURL); }; - render() { + render(): Node { return ( This app is too old! diff --git a/src/start/RealmInputScreen.js b/src/start/RealmInputScreen.js index 64ab606665d..78b02f522a9 100644 --- a/src/start/RealmInputScreen.js +++ b/src/start/RealmInputScreen.js @@ -1,5 +1,6 @@ /* @flow strict-local */ import React, { PureComponent } from 'react'; +import type { Node } from 'react'; import { Keyboard } from 'react-native'; import type { RouteProp } from '../react-navigation'; @@ -23,13 +24,13 @@ type State = {| |}; export default class RealmInputScreen extends PureComponent { - state = { + state: State = { progress: false, realmInputValue: '', error: null, }; - tryRealm = async () => { + tryRealm: () => Promise = async () => { const { realmInputValue } = this.state; const parsedRealm = tryParseUrl(realmInputValue); @@ -60,9 +61,9 @@ export default class RealmInputScreen extends PureComponent { } }; - handleRealmChange = (value: string) => this.setState({ realmInputValue: value }); + handleRealmChange: string => void = value => this.setState({ realmInputValue: value }); - render() { + render(): Node { const { navigation } = this.props; const { progress, error, realmInputValue } = this.state; diff --git a/src/streams/EditStreamCard.js b/src/streams/EditStreamCard.js index f936879dc0d..9e0c825e293 100644 --- a/src/streams/EditStreamCard.js +++ b/src/streams/EditStreamCard.js @@ -1,5 +1,6 @@ /* @flow strict-local */ import React, { PureComponent } from 'react'; +import type { Node } from 'react'; import { View } from 'react-native'; import { Input, Label, SwitchRow, ZulipButton } from '../common'; @@ -30,31 +31,31 @@ type State = {| |}; export default class EditStreamCard extends PureComponent { - state = { + state: State = { name: this.props.initialValues.name, description: this.props.initialValues.description, isPrivate: this.props.initialValues.invite_only, }; - handlePerformAction = () => { + handlePerformAction: () => void = () => { const { onComplete } = this.props; const { name, description, isPrivate } = this.state; onComplete(name, description, isPrivate); }; - handleNameChange = (name: string) => { + handleNameChange: string => void = name => { this.setState({ name }); }; - handleDescriptionChange = (description: string) => { + handleDescriptionChange: string => void = description => { this.setState({ description }); }; - handleIsPrivateChange = (isPrivate: boolean) => { + handleIsPrivateChange: boolean => void = isPrivate => { this.setState({ isPrivate }); }; - render() { + render(): Node { const { initialValues, isNewStream } = this.props; const { name } = this.state; diff --git a/src/user-picker/AvatarItem.js b/src/user-picker/AvatarItem.js index 7517a8472b5..f721948d502 100644 --- a/src/user-picker/AvatarItem.js +++ b/src/user-picker/AvatarItem.js @@ -48,7 +48,7 @@ export default class AvatarItem extends PureComponent { }).start(); } - handlePress = () => { + handlePress: () => void = () => { const { user, onPress } = this.props; Animated.timing(this.animatedValue, { toValue: 0,