diff --git a/src/RootErrorBoundary.js b/src/RootErrorBoundary.js index 4c1520cf957..d29e80993c8 100644 --- a/src/RootErrorBoundary.js +++ b/src/RootErrorBoundary.js @@ -33,7 +33,7 @@ type State = $ReadOnly<{| * [1] https://reactjs.org/docs/error-boundaries.html#how-about-event-handlers */ export default class ErrorBoundary extends React.Component { - static getDerivedStateFromError(error: Error) { + static getDerivedStateFromError(error: Error): State { return { error }; } @@ -57,11 +57,11 @@ export default class ErrorBoundary extends React.Component { logging.error(error, errorInfo); } - state = { + state: State = { error: null, }; - render() { + render(): React$Node { const { error } = this.state; if (error) { const details = `${error.toString()} diff --git a/src/account-info/AwayStatusSwitch.js b/src/account-info/AwayStatusSwitch.js index 5742dc1003e..9fbf0c6647b 100644 --- a/src/account-info/AwayStatusSwitch.js +++ b/src/account-info/AwayStatusSwitch.js @@ -13,7 +13,7 @@ type Props = $ReadOnly<{||}>; * * retrieves the current user's `user status` data and presents it * * allows by switching it to control the `away` status */ -export default function AwayStatusSwitch(props: Props) { +export default function AwayStatusSwitch(props: Props): React$Node { const awayStatus = useSelector(getSelfUserAwayStatus); const dispatch = useDispatch(); diff --git a/src/account-info/ProfileScreen.js b/src/account-info/ProfileScreen.js index 050317b0d7c..2082c974d29 100644 --- a/src/account-info/ProfileScreen.js +++ b/src/account-info/ProfileScreen.js @@ -102,7 +102,7 @@ type Props = $ReadOnly<{| * * The user can still open `AccountDetails` on themselves via the (i) icon in a chat screen. */ -export default function ProfileScreen(props: Props) { +export default function ProfileScreen(props: Props): React$Node { const ownUser = useSelector(getOwnUser); return ( diff --git a/src/account/AccountItem.js b/src/account/AccountItem.js index f9b7fb38f9f..118e58d15d5 100644 --- a/src/account/AccountItem.js +++ b/src/account/AccountItem.js @@ -47,7 +47,7 @@ type Props = $ReadOnly<{| onRemove: (index: number) => Promise | void, |}>; -export default function AccountItem(props: Props) { +export default function AccountItem(props: Props): React$Node { const { email, realm, isLoggedIn } = props.account; const showDoneIcon = props.index === 0 && isLoggedIn; diff --git a/src/account/AccountList.js b/src/account/AccountList.js index da409533555..9b5d22b25d4 100644 --- a/src/account/AccountList.js +++ b/src/account/AccountList.js @@ -12,7 +12,7 @@ type Props = $ReadOnly<{| onAccountRemove: number => Promise | void, |}>; -export default function AccountList(props: Props) { +export default function AccountList(props: Props): React$Node { const { accounts, onAccountSelect, onAccountRemove } = props; return ( diff --git a/src/account/AccountPickScreen.js b/src/account/AccountPickScreen.js index 458402c42be..38f745ec613 100644 --- a/src/account/AccountPickScreen.js +++ b/src/account/AccountPickScreen.js @@ -26,7 +26,7 @@ type Props = $ReadOnly<{| route: RouteProp<'account-pick', void>, |}>; -export default function AccountPickScreen(props: Props) { +export default function AccountPickScreen(props: Props): React$Node { const { navigation } = props; const accounts = useSelector(getAccountStatuses); const dispatch = useDispatch(); diff --git a/src/animation/AnimatedRotateComponent.js b/src/animation/AnimatedRotateComponent.js index dfa89a2f0a2..fb4b5caa68c 100644 --- a/src/animation/AnimatedRotateComponent.js +++ b/src/animation/AnimatedRotateComponent.js @@ -2,6 +2,7 @@ import React, { PureComponent } from 'react'; import type { Node as React$Node } from 'react'; import { Animated, Easing } from 'react-native'; +import type AnimatedValue from 'react-native/Libraries/Animated/src/nodes/AnimatedValue'; import type { Style } from '../types'; @@ -11,7 +12,7 @@ type Props = $ReadOnly<{| |}>; export default class AnimatedRotateComponent extends PureComponent { - rotation = new Animated.Value(0); + rotation: AnimatedValue = new Animated.Value(0); componentDidMount() { this.rotation.setValue(0); @@ -23,7 +24,7 @@ export default class AnimatedRotateComponent extends PureComponent { }).start(); } - render() { + render(): React$Node { const { children, style } = this.props; const rotation = this.rotation.interpolate({ inputRange: [0, 360], diff --git a/src/animation/AnimatedScaleComponent.js b/src/animation/AnimatedScaleComponent.js index 59e083e5b24..dac7cc0e5a3 100644 --- a/src/animation/AnimatedScaleComponent.js +++ b/src/animation/AnimatedScaleComponent.js @@ -2,6 +2,7 @@ import React, { PureComponent } from 'react'; import type { Node as React$Node } from 'react'; import { Animated, Easing } from 'react-native'; +import type AnimatedValue from 'react-native/Libraries/Animated/src/nodes/AnimatedValue'; import type { Style } from '../types'; @@ -16,11 +17,11 @@ type State = {| |}; export default class AnimatedScaleComponent extends PureComponent { - state = { + state: State = { visible: this.props.visible, }; - animatedValue = new Animated.Value(this.props.visible ? 1 : 0); + animatedValue: AnimatedValue = new Animated.Value(this.props.visible ? 1 : 0); UNSAFE_componentWillReceiveProps(nextProps: Props) { if (nextProps.visible) { @@ -34,7 +35,7 @@ export default class AnimatedScaleComponent extends PureComponent }).start(() => this.setState({ visible: nextProps.visible })); } - render() { + render(): React$Node { const { children, style } = this.props; const { visible } = this.state; const animatedStyle = { diff --git a/src/autocomplete/EmojiAutocomplete.js b/src/autocomplete/EmojiAutocomplete.js index 28671de3abe..5bf739d8ae1 100644 --- a/src/autocomplete/EmojiAutocomplete.js +++ b/src/autocomplete/EmojiAutocomplete.js @@ -16,7 +16,7 @@ type Props = $ReadOnly<{| const MAX_CHOICES = 30; -export default function EmojiAutocomplete(props: Props) { +export default function EmojiAutocomplete(props: Props): React$Node { const { filter, onAutocomplete } = props; const activeImageEmojiByName = useSelector(getActiveImageEmojiByName); const emojiNames = getFilteredEmojis(filter, activeImageEmojiByName); diff --git a/src/autocomplete/PeopleAutocomplete.js b/src/autocomplete/PeopleAutocomplete.js index b870fcf1438..28237015593 100644 --- a/src/autocomplete/PeopleAutocomplete.js +++ b/src/autocomplete/PeopleAutocomplete.js @@ -21,7 +21,7 @@ type Props = $ReadOnly<{| onAutocomplete: (name: string) => void, |}>; -export default function PeopleAutocomplete(props: Props) { +export default function PeopleAutocomplete(props: Props): React$Node { const { filter, onAutocomplete } = props; const mutedUsers = useSelector(getMutedUsers); const ownUserId = useSelector(getOwnUserId); diff --git a/src/autocomplete/StreamAutocomplete.js b/src/autocomplete/StreamAutocomplete.js index 8dfee8bc96f..4cf2aa4126f 100644 --- a/src/autocomplete/StreamAutocomplete.js +++ b/src/autocomplete/StreamAutocomplete.js @@ -13,7 +13,7 @@ type Props = $ReadOnly<{| onAutocomplete: (name: string) => void, |}>; -export default function StreamAutocomplete(props: Props) { +export default function StreamAutocomplete(props: Props): React$Node { const { filter, onAutocomplete } = props; const subscriptions = useSelector(getSubscribedStreams); diff --git a/src/boot/AppDataFetcher.js b/src/boot/AppDataFetcher.js index 745bc176340..c634c8afea0 100644 --- a/src/boot/AppDataFetcher.js +++ b/src/boot/AppDataFetcher.js @@ -11,7 +11,7 @@ type Props = $ReadOnly<{| children: React$Node, |}>; -export default function AppDataFetcher(props: Props) { +export default function AppDataFetcher(props: Props): React$Node { const needsInitialFetch = useSelector(state => getSession(state).needsInitialFetch); const dispatch = useDispatch(); diff --git a/src/boot/CompatibilityChecker.js b/src/boot/CompatibilityChecker.js index 50768f558bd..7d737498c9f 100644 --- a/src/boot/CompatibilityChecker.js +++ b/src/boot/CompatibilityChecker.js @@ -14,7 +14,7 @@ type State = {| |}; export default class CompatibilityChecker extends PureComponent { - state = { + state: State = { compatibilityCheckFail: false, }; @@ -28,7 +28,7 @@ export default class CompatibilityChecker extends PureComponent { }); } - render() { + render(): React$Node { const { compatibilityCheckFail } = this.state; return compatibilityCheckFail ? : this.props.children; diff --git a/src/boot/HideIfNotHydrated.js b/src/boot/HideIfNotHydrated.js index a4a526173e3..ec8479b2a24 100644 --- a/src/boot/HideIfNotHydrated.js +++ b/src/boot/HideIfNotHydrated.js @@ -10,7 +10,7 @@ type Props = $ReadOnly<{| PlaceholderComponent?: React$ComponentType<{||}>, |}>; -export default function HideIfNotHydrated(props: Props) { +export default function HideIfNotHydrated(props: Props): React$Node { const isHydrated = useSelector(getIsHydrated); const { children, PlaceholderComponent } = props; diff --git a/src/boot/StoreProvider.js b/src/boot/StoreProvider.js index b56f5b89642..45531215296 100644 --- a/src/boot/StoreProvider.js +++ b/src/boot/StoreProvider.js @@ -38,7 +38,7 @@ export default class StoreProvider extends PureComponent { } } - render() { + render(): React$Node { return {this.props.children}; } } diff --git a/src/boot/ThemeProvider.js b/src/boot/ThemeProvider.js index 6b85d0798ce..bd0fcac43fc 100644 --- a/src/boot/ThemeProvider.js +++ b/src/boot/ThemeProvider.js @@ -12,7 +12,7 @@ type Props = $ReadOnly<{| children: React$Node, |}>; -export default function ThemeProvider(props: Props) { +export default function ThemeProvider(props: Props): React$Node { const { children } = props; const theme = useSelector(state => getSettings(state).theme); return ( diff --git a/src/boot/TranslationProvider.js b/src/boot/TranslationProvider.js index e8df12a46b3..81f51a76c9c 100644 --- a/src/boot/TranslationProvider.js +++ b/src/boot/TranslationProvider.js @@ -76,7 +76,7 @@ type Props = $ReadOnly<{| children: React$Node, |}>; -export default function TranslationProvider(props: Props) { +export default function TranslationProvider(props: Props): React$Node { const { children } = props; const locale = useSelector(state => getSettings(state).locale); diff --git a/src/chat/ChatScreen.js b/src/chat/ChatScreen.js index 8ec2ef5bf9a..c24070cb111 100644 --- a/src/chat/ChatScreen.js +++ b/src/chat/ChatScreen.js @@ -97,7 +97,7 @@ const useMessagesWithFetch = args => { return { fetchError, isFetching, messages, haveNoMessages, firstUnreadIdInNarrow }; }; -export default function ChatScreen(props: Props) { +export default function ChatScreen(props: Props): React$Node { const { route, navigation } = props; const { backgroundColor } = React.useContext(ThemeContext); diff --git a/src/chat/FetchError.js b/src/chat/FetchError.js index 5c554bff084..825ece115a0 100644 --- a/src/chat/FetchError.js +++ b/src/chat/FetchError.js @@ -26,7 +26,7 @@ type Props = $ReadOnly<{| |}>; export default class FetchError extends PureComponent { - render() { + render(): React$Node { return ( {(() => { diff --git a/src/chat/InvalidNarrow.js b/src/chat/InvalidNarrow.js index 4b9f4596861..3ceae03c87b 100644 --- a/src/chat/InvalidNarrow.js +++ b/src/chat/InvalidNarrow.js @@ -24,7 +24,7 @@ type Props = $ReadOnly<{| |}>; export default class InvalidNarrow extends PureComponent { - render() { + render(): React$Node { return (