@samitouri / QOS-React / commits / b2d16047ae

Fix Type for ReactNative.NativeComponent (#12805)

Timothy Yung committed May 14, 2018 at 16:36 UTC b2d16047ae8a6405983e8244bf3b482bc57cd5a4
3 files changed +22 -7
packages/react-native-renderer/src/ReactNativeTypes.js
+21 -3
@@ -4,10 +4,12 @@
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 + * @format
8 * @flow
8 - * @providesModule ReactNativeTypes
9 */
10
11 +import React from 'react';
12 +
13 export type MeasureOnSuccessCallback = (
14 x: number,
15 y: number,
@@ -52,6 +54,22 @@ export type ReactNativeBaseComponentViewConfig = {
54
55 export type ViewConfigGetter = () => ReactNativeBaseComponentViewConfig;
56
57 +/**
58 + * Class only exists for its Flow type.
59 + */
60 +class ReactNativeComponent<Props> extends React.Component<Props> {
61 + blur(): void {}
62 + focus(): void {}
63 + measure(callback: MeasureOnSuccessCallback): void {}
64 + measureInWindow(callback: MeasureInWindowOnSuccessCallback): void {}
65 + measureLayout(
66 + relativeToNativeNode: number,
67 + onSuccess: MeasureLayoutOnSuccessCallback,
68 + onFail?: () => void,
69 + ): void {}
70 + setNativeProps(nativeProps: Object): void {}
71 +}
72 +
73 /**
74 * This type keeps ReactNativeFiberHostComponent and NativeMethodsMixin in sync.
75 * It can also provide types for ReactNative applications that use NMM or refs.
@@ -87,7 +105,7 @@ type SecretInternalsFabricType = {
105 * Provide minimal Flow typing for the high-level RN API and call it a day.
106 */
107 export type ReactNativeType = {
90 - NativeComponent: any,
108 + NativeComponent: typeof ReactNativeComponent,
109 findNodeHandle(componentOrHandle: any): ?number,
110 render(
111 element: React$Element<any>,
@@ -102,7 +120,7 @@ export type ReactNativeType = {
120 };
121
122 export type ReactFabricType = {
105 - NativeComponent: any,
123 + NativeComponent: typeof ReactNativeComponent,
124 findNodeHandle(componentOrHandle: any): ?number,
125 render(
126 element: React$Element<any>,
packages/shared/ReactTypes.js
-1
@@ -5,7 +5,6 @@
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @flow
8 - * @providesModule ReactTypes
8 */
9
10 export type ReactNode =
scripts/circleci/check_modules.sh
+1 -3
@@ -3,9 +3,7 @@
3 set -e
4
5 # Make sure we don't introduce accidental @providesModule annotations.
6 -EXPECTED='packages/react-native-renderer/src/ReactNativeTypes.js
7 -packages/shared/ReactTypes.js
8 -scripts/rollup/wrappers.js'
6 +EXPECTED='scripts/rollup/wrappers.js'
7 ACTUAL=$(git grep -l @providesModule -- './*.js' ':!scripts/rollup/shims/*.js')
8
9 # Colors