Skip to content

Commit 10c8352

Browse files
sahrensfacebook-github-bot
authored andcommitted
Fix flow typing of Text
Summary: Make Text prop types exact to catch tons of errors, including typos like in https://fb.workplace.com/groups/rn.support/permalink/2306953619353240/. I tried to fix things when it was totally obvious what the intent was, but otherwise tried to keep the existing behavior the same, even if it meant that usage of some props was getting ignored, like `hitSlop`. Reviewed By: TheSavior Differential Revision: D13892999 fbshipit-source-id: 5003508a648287e4eca8055fb59da5f03bd066cc
1 parent cae6bef commit 10c8352

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

Libraries/Text/Text.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ type ResponseHandlers = $ReadOnly<{|
3434
onResponderTerminationRequest: () => boolean,
3535
|}>;
3636

37-
type Props = $ReadOnly<{
37+
type Props = $ReadOnly<{|
3838
...TextProps,
3939
forwardedRef: ?React.Ref<'RCTText' | 'RCTVirtualText'>,
40-
}>;
40+
|}>;
4141

4242
type State = {|
4343
touchable: {|
@@ -286,7 +286,6 @@ TextToExport.displayName = 'Text';
286286
* and run Flow. */
287287
TextToExport.propTypes = DeprecatedTextPropTypes;
288288

289-
/* $FlowFixMe(>=0.89.0 site=react_native_fb) This comment suppresses an error
290-
* found when Flow v0.89 was deployed. To see the error, delete this comment
291-
* and run Flow. */
292-
module.exports = (TextToExport: Class<NativeComponent<TextProps>>);
289+
module.exports = ((TextToExport: $FlowFixMe): Class<
290+
NativeComponent<TextProps>,
291+
>);

Libraries/Text/TextProps.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ export type PressRetentionOffset = $ReadOnly<{|
2929
/**
3030
* @see https://facebook.github.io/react-native/docs/text.html#reference
3131
*/
32-
export type TextProps = $ReadOnly<{
32+
export type TextProps = $ReadOnly<{|
3333
/**
3434
* Indicates whether the view is an accessibility element.
3535
*
3636
* See https://facebook.github.io/react-native/docs/text.html#accessible
3737
*/
3838
accessible?: ?boolean,
39+
accessibilityHint?: ?Stringish,
40+
accessibilityLabel?: ?Stringish,
3941
accessibilityRole?: ?AccessibilityRole,
4042
accessibilityStates?: ?AccessibilityStates,
4143
accessibilityTraits?: ?(AccessibilityTrait | Array<AccessibilityTrait>),
@@ -112,6 +114,7 @@ export type TextProps = $ReadOnly<{
112114
onResponderTerminate?: ?(event: PressEvent) => void,
113115
onResponderTerminationRequest?: ?() => boolean,
114116
onStartShouldSetResponder?: ?() => boolean,
117+
onMoveShouldSetResponder?: ?() => boolean,
115118
onTextLayout?: ?(event: TextLayoutEvent) => mixed,
116119

117120
/**
@@ -180,4 +183,4 @@ export type TextProps = $ReadOnly<{
180183
* See https://facebook.github.io/react-native/docs/text.html#supperhighlighting
181184
*/
182185
suppressHighlighting?: ?boolean,
183-
}>;
186+
|}>;

RNTester/js/TextInputExample.ios.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ exports.examples = [
630630
<WithLabel label="singleline">
631631
<TextInput style={styles.default} value="(value property)">
632632
(first raw text node)
633-
<Text color="red">(internal raw text node)</Text>
633+
<Text style={{color: 'red'}}>(internal raw text node)</Text>
634634
(last raw text node)
635635
</TextInput>
636636
</WithLabel>
@@ -640,7 +640,7 @@ exports.examples = [
640640
multiline={true}
641641
value="(value property)">
642642
(first raw text node)
643-
<Text color="red">(internal raw text node)</Text>
643+
<Text style={{color: 'red'}}>(internal raw text node)</Text>
644644
(last raw text node)
645645
</TextInput>
646646
</WithLabel>

0 commit comments

Comments
 (0)