Fixed Flow typing of TextInput refs

Summary:
`React.ElementRef<HostComponent<mixed>>` 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
This commit is contained in:
Sam Goldman
2021-03-02 00:28:03 -08:00
committed by Facebook GitHub Bot
parent ce8440c77c
commit 62fcb4e22c
2 changed files with 4 additions and 3 deletions
+2
View File
@@ -373,6 +373,8 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
| ?React.ElementRef<typeof View>
| ?React.ElementRef<ScrollViewNativeComponent> {
if (this._listRef) {
/* $FlowFixMe[incompatible-return] Suppresses errors found when fixing
* TextInput typing */
return this._listRef.getScrollRef();
}
}
+2 -3
View File
@@ -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<T> = AbstractComponent<T, $ReadOnly<NativeMethods>>;