From d8d7edde5d9de832039e971ad744002ed8f5fa4b Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Mon, 28 Aug 2017 14:39:58 -0700 Subject: [PATCH] Upgrade flow-bin to 0.53.1 (#10510) * Update flow-bin to 0.53.1 * Ran flow-upgrade utility Manually corrected a few over-eager cases where it tried to replace our ReactElement sub-type. * Replaced a couple of React.Element types with React * Removed temporary ReactComponent/ReactComponent Flow types * Prettier * Replaced React with React based on Dan's PR feedback --- .flowconfig | 2 +- flow/environment.js | 6 +----- flow/react-native-host-hooks.js | 2 +- package.json | 2 +- src/renderers/dom/fiber/ReactDOMFiberEntry.js | 14 +++++--------- src/renderers/dom/shared/findDOMNode.js | 2 +- .../dom/stack/server/ReactServerUpdateQueue.js | 10 +++++----- src/renderers/native/ReactNativeComponent.js | 2 +- src/renderers/native/ReactNativeFiberEntry.js | 2 +- src/renderers/native/ReactNativeTypes.js | 4 +--- src/renderers/native/takeSnapshot.js | 2 +- src/renderers/noop/ReactNoopEntry.js | 6 +++--- src/renderers/shared/fiber/ReactFiberReconciler.js | 8 ++++---- src/renderers/shared/fiber/ReactFiberScheduler.js | 6 ++++-- .../shared/fiber/ReactFiberTreeReflection.js | 4 +--- .../shared/fiber/isomorphic/ReactTypes.js | 6 +++--- .../shared/shared/event/ReactSyntheticEventType.js | 2 +- .../shared/shared/getContextForSubtree.js | 2 +- .../shared/stack/reconciler/ReactNodeTypes.js | 2 +- .../stack/reconciler/flattenStackChildren.js | 6 +++--- .../testing/ReactTestRendererFiberEntry.js | 6 +++--- src/shared/ReactElementType.js | 2 +- yarn.lock | 6 +++--- 23 files changed, 47 insertions(+), 57 deletions(-) diff --git a/.flowconfig b/.flowconfig index 0f4ca65f6a..9c8275381a 100644 --- a/.flowconfig +++ b/.flowconfig @@ -39,4 +39,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError [version] -^0.52.0 +^0.53.1 diff --git a/flow/environment.js b/flow/environment.js index fa020bf8aa..2cd99b9882 100644 --- a/flow/environment.js +++ b/flow/environment.js @@ -13,8 +13,4 @@ declare var __REACT_DEVTOOLS_GLOBAL_HOOK__: any; /*?{ inject: ?((stuff: Object) => void) -};*/ - -// temporary patches for React.Component and React.Element -declare var ReactComponent: typeof React$Component; -declare var ReactElement: typeof React$Element; +};*/ \ No newline at end of file diff --git a/flow/react-native-host-hooks.js b/flow/react-native-host-hooks.js index d1c332fc9c..11db414b1f 100644 --- a/flow/react-native-host-hooks.js +++ b/flow/react-native-host-hooks.js @@ -83,5 +83,5 @@ declare module 'UIManager' { ) : Promise; } declare module 'View' { - declare var exports : typeof ReactComponent; + declare var exports : typeof React$Component; } diff --git a/package.json b/package.json index 90511293b6..bd3033c628 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "fbjs": "^0.8.9", "fbjs-scripts": "^0.6.0", "filesize": "^3.5.6", - "flow-bin": "^0.52.0", + "flow-bin": "^0.53.1", "git-branch": "^0.3.0", "glob": "^6.0.4", "glob-stream": "^6.1.0", diff --git a/src/renderers/dom/fiber/ReactDOMFiberEntry.js b/src/renderers/dom/fiber/ReactDOMFiberEntry.js index e7a2594712..f340a2a6de 100644 --- a/src/renderers/dom/fiber/ReactDOMFiberEntry.js +++ b/src/renderers/dom/fiber/ReactDOMFiberEntry.js @@ -546,7 +546,7 @@ ReactGenericBatching.injection.injectFiberBatchedUpdates( var warnedAboutHydrateAPI = false; function renderSubtreeIntoContainer( - parentComponent: ?ReactComponent, + parentComponent: ?React$Component, children: ReactNodeList, container: DOMContainer, forceHydrate: boolean, @@ -649,17 +649,13 @@ function renderSubtreeIntoContainer( } var ReactDOMFiber = { - hydrate( - element: ReactElement, - container: DOMContainer, - callback: ?Function, - ) { + hydrate(element: React$Node, container: DOMContainer, callback: ?Function) { // TODO: throw or warn if we couldn't hydrate? return renderSubtreeIntoContainer(null, element, container, true, callback); }, render( - element: ReactElement, + element: React$Element, container: DOMContainer, callback: ?Function, ) { @@ -705,8 +701,8 @@ var ReactDOMFiber = { }, unstable_renderSubtreeIntoContainer( - parentComponent: ReactComponent, - element: ReactElement, + parentComponent: React$Component, + element: React$Element, containerNode: DOMContainer, callback: ?Function, ) { diff --git a/src/renderers/dom/shared/findDOMNode.js b/src/renderers/dom/shared/findDOMNode.js index e228ddb5e4..109b225c94 100644 --- a/src/renderers/dom/shared/findDOMNode.js +++ b/src/renderers/dom/shared/findDOMNode.js @@ -29,7 +29,7 @@ let findStack = function(arg) { }; const findDOMNode = function( - componentOrElement: Element | ?ReactComponent, + componentOrElement: Element | ?React$Component, ): null | Element | Text { if (__DEV__) { var owner = (ReactCurrentOwner.current: any); diff --git a/src/renderers/dom/stack/server/ReactServerUpdateQueue.js b/src/renderers/dom/stack/server/ReactServerUpdateQueue.js index fa6c99e3e0..d6d2e131ce 100644 --- a/src/renderers/dom/stack/server/ReactServerUpdateQueue.js +++ b/src/renderers/dom/stack/server/ReactServerUpdateQueue.js @@ -19,7 +19,7 @@ var warning = require('fbjs/lib/warning'); import type {Transaction} from 'Transaction'; function warnNoop( - publicInstance: ReactComponent, + publicInstance: React$Component, callerName: string, ) { if (__DEV__) { @@ -58,7 +58,7 @@ class ReactServerUpdateQueue { * @protected * @final */ - isMounted(publicInstance: ReactComponent): boolean { + isMounted(publicInstance: React$Component): boolean { return false; } @@ -78,7 +78,7 @@ class ReactServerUpdateQueue { * @internal */ enqueueForceUpdate( - publicInstance: ReactComponent, + publicInstance: React$Component, callback?: Function, callerName?: string, ) { @@ -103,7 +103,7 @@ class ReactServerUpdateQueue { * @internal */ enqueueReplaceState( - publicInstance: ReactComponent, + publicInstance: React$Component, completeState: Object | Function, callback?: Function, callerName?: string, @@ -131,7 +131,7 @@ class ReactServerUpdateQueue { * @internal */ enqueueSetState( - publicInstance: ReactComponent, + publicInstance: React$Component, partialState: Object | Function, callback?: Function, callerName?: string, diff --git a/src/renderers/native/ReactNativeComponent.js b/src/renderers/native/ReactNativeComponent.js index 91210af31a..1e2e2a01e3 100644 --- a/src/renderers/native/ReactNativeComponent.js +++ b/src/renderers/native/ReactNativeComponent.js @@ -45,7 +45,7 @@ import type { * @abstract */ class ReactNativeComponent - extends React.Component { + extends React.Component { static defaultProps: $Abstract; props: Props; state: $Abstract; diff --git a/src/renderers/native/ReactNativeFiberEntry.js b/src/renderers/native/ReactNativeFiberEntry.js index 3dd78acf40..99ef774daf 100644 --- a/src/renderers/native/ReactNativeFiberEntry.js +++ b/src/renderers/native/ReactNativeFiberEntry.js @@ -48,7 +48,7 @@ const ReactNativeFiber: ReactNativeType = { findNodeHandle: findNumericNodeHandle, - render(element: ReactElement, containerTag: any, callback: ?Function) { + render(element: React$Element, containerTag: any, callback: ?Function) { let root = roots.get(containerTag); if (!root) { diff --git a/src/renderers/native/ReactNativeTypes.js b/src/renderers/native/ReactNativeTypes.js index 3dbc7deeef..4d9da467cd 100644 --- a/src/renderers/native/ReactNativeTypes.js +++ b/src/renderers/native/ReactNativeTypes.js @@ -11,8 +11,6 @@ */ 'use strict'; -import type React from 'react'; - export type MeasureOnSuccessCallback = ( x: number, y: number, @@ -78,7 +76,7 @@ export type ReactNativeType = { NativeComponent: any, findNodeHandle(componentOrHandle: any): ?number, render( - element: React.Element, + element: React$Element, containerTag: any, callback: ?Function, ): any, diff --git a/src/renderers/native/takeSnapshot.js b/src/renderers/native/takeSnapshot.js index 5fa0df2028..60b86b74ef 100644 --- a/src/renderers/native/takeSnapshot.js +++ b/src/renderers/native/takeSnapshot.js @@ -33,7 +33,7 @@ const findNumericNodeHandle = require('findNumericNodeHandle'); * @platform ios */ function takeSnapshot( - view?: 'window' | ReactElement | number, + view?: 'window' | React$Element | number, options?: { width?: number, height?: number, diff --git a/src/renderers/noop/ReactNoopEntry.js b/src/renderers/noop/ReactNoopEntry.js index bd9a21d124..1e5cc03260 100644 --- a/src/renderers/noop/ReactNoopEntry.js +++ b/src/renderers/noop/ReactNoopEntry.js @@ -251,12 +251,12 @@ var ReactNoop = { }, // Shortcut for testing a single root - render(element: ReactElement, callback: ?Function) { + render(element: React$Element, callback: ?Function) { ReactNoop.renderToRootWithID(element, DEFAULT_ROOT_ID, callback); }, renderToRootWithID( - element: ReactElement, + element: React$Element, rootID: string, callback: ?Function, ) { @@ -281,7 +281,7 @@ var ReactNoop = { }, findInstance( - componentOrElement: Element | ?ReactComponent, + componentOrElement: Element | ?React$Component, ): null | Instance | TextInstance { if (componentOrElement == null) { return null; diff --git a/src/renderers/shared/fiber/ReactFiberReconciler.js b/src/renderers/shared/fiber/ReactFiberReconciler.js index 2edad98499..9166c66a24 100644 --- a/src/renderers/shared/fiber/ReactFiberReconciler.js +++ b/src/renderers/shared/fiber/ReactFiberReconciler.js @@ -160,7 +160,7 @@ export type Reconciler = { updateContainer( element: ReactNodeList, container: OpaqueRoot, - parentComponent: ?ReactComponent, + parentComponent: ?React$Component, callback: ?Function, ): void, performWithPriority(priorityLevel: PriorityLevel, fn: Function): void, @@ -172,7 +172,7 @@ export type Reconciler = { // Used to extract the return value from the initial render. Legacy API. getPublicRootInstance( container: OpaqueRoot, - ): ReactComponent | TI | I | null, + ): React$Component | TI | I | null, // Use for findDOMNode/findHostNode. Legacy API. findHostInstance(component: Fiber): I | TI | null, @@ -256,7 +256,7 @@ module.exports = function( updateContainer( element: ReactNodeList, container: OpaqueRoot, - parentComponent: ?ReactComponent, + parentComponent: ?React$Component, callback: ?Function, ): void { // TODO: If this is a nested container, this won't be the root. @@ -296,7 +296,7 @@ module.exports = function( getPublicRootInstance( container: OpaqueRoot, - ): ReactComponent | PI | null { + ): React$Component | PI | null { const containerFiber = container.current; if (!containerFiber.child) { return null; diff --git a/src/renderers/shared/fiber/ReactFiberScheduler.js b/src/renderers/shared/fiber/ReactFiberScheduler.js index be8545fcac..6be2c5fda8 100644 --- a/src/renderers/shared/fiber/ReactFiberScheduler.js +++ b/src/renderers/shared/fiber/ReactFiberScheduler.js @@ -111,7 +111,9 @@ if (__DEV__) { stopCommitLifeCyclesTimer, } = require('ReactDebugFiberPerf'); - var warnAboutUpdateOnUnmounted = function(instance: ReactClass) { + var warnAboutUpdateOnUnmounted = function( + instance: React$ComponentType, + ) { const ctor = instance.constructor; warning( false, @@ -123,7 +125,7 @@ if (__DEV__) { ); }; - var warnAboutInvalidUpdates = function(instance: ReactClass) { + var warnAboutInvalidUpdates = function(instance: React$ComponentType) { switch (ReactDebugCurrentFiber.phase) { case 'getChildContext': warning( diff --git a/src/renderers/shared/fiber/ReactFiberTreeReflection.js b/src/renderers/shared/fiber/ReactFiberTreeReflection.js index 33ddf1bf1b..914d3f1d0e 100644 --- a/src/renderers/shared/fiber/ReactFiberTreeReflection.js +++ b/src/renderers/shared/fiber/ReactFiberTreeReflection.js @@ -70,9 +70,7 @@ exports.isFiberMounted = function(fiber: Fiber): boolean { return isFiberMountedImpl(fiber) === MOUNTED; }; -exports.isMounted = function( - component: ReactComponent, -): boolean { +exports.isMounted = function(component: React$Component): boolean { if (__DEV__) { const owner = (ReactCurrentOwner.current: any); if (owner !== null && owner.tag === ClassComponent) { diff --git a/src/renderers/shared/fiber/isomorphic/ReactTypes.js b/src/renderers/shared/fiber/isomorphic/ReactTypes.js index f63948d403..8af1831884 100644 --- a/src/renderers/shared/fiber/isomorphic/ReactTypes.js +++ b/src/renderers/shared/fiber/isomorphic/ReactTypes.js @@ -13,16 +13,16 @@ 'use strict'; export type ReactNode = - | ReactElement + | React$Element | ReactCoroutine | ReactYield | ReactPortal | ReactText | ReactFragment; -export type ReactFragment = ReactEmpty | Iterable; +export type ReactFragment = ReactEmpty | Iterable; -export type ReactNodeList = ReactEmpty | ReactNode; +export type ReactNodeList = ReactEmpty | React$Node; export type ReactText = string | number; diff --git a/src/renderers/shared/shared/event/ReactSyntheticEventType.js b/src/renderers/shared/shared/event/ReactSyntheticEventType.js index 3496d633c9..39f4e50067 100644 --- a/src/renderers/shared/shared/event/ReactSyntheticEventType.js +++ b/src/renderers/shared/shared/event/ReactSyntheticEventType.js @@ -33,4 +33,4 @@ export type ReactSyntheticEvent = { nativeTarget: Event, nativeEventTarget: EventTarget, ) => ReactSyntheticEvent, -} & SyntheticEvent; +} & SyntheticEvent<>; diff --git a/src/renderers/shared/shared/getContextForSubtree.js b/src/renderers/shared/shared/getContextForSubtree.js index 2883e36834..dea20b336e 100644 --- a/src/renderers/shared/shared/getContextForSubtree.js +++ b/src/renderers/shared/shared/getContextForSubtree.js @@ -20,7 +20,7 @@ let getContextFiber = function(arg) { }; function getContextForSubtree( - parentComponent: ?ReactComponent, + parentComponent: ?React$Component, ): Object { if (!parentComponent) { return emptyObject; diff --git a/src/renderers/shared/stack/reconciler/ReactNodeTypes.js b/src/renderers/shared/stack/reconciler/ReactNodeTypes.js index 2e24a6ba10..7e88f313e9 100644 --- a/src/renderers/shared/stack/reconciler/ReactNodeTypes.js +++ b/src/renderers/shared/stack/reconciler/ReactNodeTypes.js @@ -23,7 +23,7 @@ var ReactNodeTypes = { COMPOSITE: 1, EMPTY: 2, - getType: function(node: ReactElement): ReactNodeType { + getType: function(node: React$Element): ReactNodeType { if (node === null || node === false) { return ReactNodeTypes.EMPTY; } else if (React.isValidElement(node)) { diff --git a/src/renderers/shared/stack/reconciler/flattenStackChildren.js b/src/renderers/shared/stack/reconciler/flattenStackChildren.js index 699747d839..6e2aa27659 100644 --- a/src/renderers/shared/stack/reconciler/flattenStackChildren.js +++ b/src/renderers/shared/stack/reconciler/flattenStackChildren.js @@ -43,7 +43,7 @@ if ( */ function flattenSingleChildIntoContext( traverseContext: mixed, - child: ReactElement, + child: React$Element, name: string, selfDebugID?: number, ): void { @@ -82,9 +82,9 @@ function flattenSingleChildIntoContext( * @return {!object} flattened children keyed by name. */ function flattenStackChildren( - children: ReactElement, + children: React$Element, selfDebugID?: number, -): ?{[name: string]: ReactElement} { +): ?{[name: string]: React$Element} { if (children == null) { return children; } diff --git a/src/renderers/testing/ReactTestRendererFiberEntry.js b/src/renderers/testing/ReactTestRendererFiberEntry.js index fff2175023..fa2dfa6aa3 100644 --- a/src/renderers/testing/ReactTestRendererFiberEntry.js +++ b/src/renderers/testing/ReactTestRendererFiberEntry.js @@ -32,7 +32,7 @@ import type {Fiber} from 'ReactFiber'; import type {FiberRoot} from 'ReactFiberRoot'; type TestRendererOptions = { - createNodeMock: (element: ReactElement) => any, + createNodeMock: (element: React$Element) => any, }; type ReactTestRendererJSON = {| @@ -551,7 +551,7 @@ function propsMatch(props: Object, filter: Object): boolean { } var ReactTestRendererFiber = { - create(element: ReactElement, options: TestRendererOptions) { + create(element: React$Element, options: TestRendererOptions) { var createNodeMock = defaultTestOptions.createNodeMock; if (options && typeof options.createNodeMock === 'function') { createNodeMock = options.createNodeMock; @@ -586,7 +586,7 @@ var ReactTestRendererFiber = { } return toTree(root.current); }, - update(newElement: ReactElement) { + update(newElement: React$Element) { if (root == null || root.current == null) { return; } diff --git a/src/shared/ReactElementType.js b/src/shared/ReactElementType.js index 6c91154ece..e9d6bbec5b 100644 --- a/src/shared/ReactElementType.js +++ b/src/shared/ReactElementType.js @@ -29,7 +29,7 @@ export type ReactElement = { _store: { validated: boolean, }, - _self: ReactElement, + _self: React$Element, _shadowChildren: any, _source: Source, }; diff --git a/yarn.lock b/yarn.lock index 64549ccf01..fe9befce9d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1853,9 +1853,9 @@ flat-cache@^1.2.1: graceful-fs "^4.1.2" write "^0.2.1" -flow-bin@^0.52.0: - version "0.52.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.52.0.tgz#b6d9abe8bcd1ee5c62df386451a4e2553cadc3a3" +flow-bin@^0.53.1: + version "0.53.1" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.53.1.tgz#9b22b63a23c99763ae533ebbab07f88c88c97d84" flow-parser@0.43.0: version "0.43.0"