From fb68acfa6bbfc08a2f0f9319d227b83fd93fc718 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Mon, 14 May 2018 15:48:52 -0700 Subject: [PATCH] Fix Type for ReactNative.NativeComponent --- .../src/ReactNativeTypes.js | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/react-native-renderer/src/ReactNativeTypes.js b/packages/react-native-renderer/src/ReactNativeTypes.js index bf94119739334..c38b0b44ebcf9 100644 --- a/packages/react-native-renderer/src/ReactNativeTypes.js +++ b/packages/react-native-renderer/src/ReactNativeTypes.js @@ -4,10 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * + * @format * @flow - * @providesModule ReactNativeTypes */ +import React from 'react'; + export type MeasureOnSuccessCallback = ( x: number, y: number, @@ -52,6 +54,22 @@ export type ReactNativeBaseComponentViewConfig = { export type ViewConfigGetter = () => ReactNativeBaseComponentViewConfig; +/** + * Class only exists for its Flow type. + */ +class ReactNativeComponent extends React.Component { + blur(): void {} + focus(): void {} + measure(callback: MeasureOnSuccessCallback): void {} + measureInWindow(callback: MeasureInWindowOnSuccessCallback): void {} + measureLayout( + relativeToNativeNode: number, + onSuccess: MeasureLayoutOnSuccessCallback, + onFail?: () => void, + ): void {} + setNativeProps(nativeProps: Object): void {} +} + /** * This type keeps ReactNativeFiberHostComponent and NativeMethodsMixin in sync. * It can also provide types for ReactNative applications that use NMM or refs. @@ -87,7 +105,7 @@ type SecretInternalsFabricType = { * Provide minimal Flow typing for the high-level RN API and call it a day. */ export type ReactNativeType = { - NativeComponent: any, + NativeComponent: typeof ReactNativeComponent, findNodeHandle(componentOrHandle: any): ?number, render( element: React$Element, @@ -102,7 +120,7 @@ export type ReactNativeType = { }; export type ReactFabricType = { - NativeComponent: any, + NativeComponent: typeof ReactNativeComponent, findNodeHandle(componentOrHandle: any): ?number, render( element: React$Element,