From 62fcb4e22c879e11e090c30b2ee61f4e82ff1180 Mon Sep 17 00:00:00 2001 From: Sam Goldman Date: Tue, 2 Mar 2021 00:24:36 -0800 Subject: [PATCH] Fixed Flow typing of TextInput refs Summary: `React.ElementRef>` is an inexact object type, which can not be spread into an exact object type, as is happening here. This error is masked in types-first mode, but causes the instance type of this component to be `any`. In a future version of Flow, this issue will be fixed, so this change unblocks upgrading Flow. This change is likely to cause code using `TextInput` refs to find errors which were missed before. Changelog: [General][Fixed] - Fixed Flow typing of TextInput refs Reviewed By: yungsters Differential Revision: D26733314 fbshipit-source-id: 8aa26ce5b49357b279f76dd1767a17a9fb4dd4f1 --- Libraries/Lists/FlatList.js | 2 ++ Libraries/Renderer/shims/ReactNativeTypes.js | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index 19012b8c9e5..540a865d70f 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -373,6 +373,8 @@ class FlatList extends React.PureComponent, void> { | ?React.ElementRef | ?React.ElementRef { if (this._listRef) { + /* $FlowFixMe[incompatible-return] Suppresses errors found when fixing + * TextInput typing */ return this._listRef.getScrollRef(); } } diff --git a/Libraries/Renderer/shims/ReactNativeTypes.js b/Libraries/Renderer/shims/ReactNativeTypes.js index 552b118556a..3811bfa35ad 100644 --- a/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/Libraries/Renderer/shims/ReactNativeTypes.js @@ -99,7 +99,7 @@ export type PartialViewConfig = $ReadOnly<{ validAttributes?: PartialAttributeConfiguration, }>; -export type NativeMethods = { +export type NativeMethods = {| blur(): void, focus(): void, measure(callback: MeasureOnSuccessCallback): void, @@ -110,8 +110,7 @@ export type NativeMethods = { onFail?: () => void, ): void, setNativeProps(nativeProps: {...}): void, - ... -}; +|}; export type HostComponent = AbstractComponent>;