diff --git a/Libraries/Components/View/View.js b/Libraries/Components/View/View.js index 9694a2fb39a234..5e1b6bdb57abd3 100644 --- a/Libraries/Components/View/View.js +++ b/Libraries/Components/View/View.js @@ -74,4 +74,4 @@ if (__DEV__) { ViewToExport.displayName = 'View'; } -module.exports = ((ViewToExport: any): Class>); +module.exports = ((ViewToExport: any): Class>); diff --git a/Libraries/Renderer/shims/ReactNativeTypes.js b/Libraries/Renderer/shims/ReactNativeTypes.js index 485ce162ecc6bd..1f0d1dce0b09ad 100644 --- a/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/Libraries/Renderer/shims/ReactNativeTypes.js @@ -4,9 +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 */ +import * as React from 'react'; + export type MeasureOnSuccessCallback = ( x: number, y: number, @@ -51,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. @@ -86,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, @@ -101,7 +120,7 @@ export type ReactNativeType = { }; export type ReactFabricType = { - NativeComponent: any, + NativeComponent: typeof ReactNativeComponent, findNodeHandle(componentOrHandle: any): ?number, render( element: React$Element, diff --git a/Libraries/Text/Text.js b/Libraries/Text/Text.js index 1dcac7c1a759dc..a1f9db79398ebc 100644 --- a/Libraries/Text/Text.js +++ b/Libraries/Text/Text.js @@ -36,7 +36,7 @@ type ResponseHandlers = $ReadOnly<{| type Props = $ReadOnly<{ ...TextProps, - forwardedRef: ?React.Ref>, + forwardedRef: ?React.Ref>, }>; type State = {| @@ -270,4 +270,4 @@ Text.displayName = 'Text'; // TODO: Deprecate this. Text.propTypes = TextPropTypes; -module.exports = ((Text: any): NativeComponent); +module.exports = ((Text: any): Class>);