From 6c00c5bba4d2272de6975c124ab6dc29abb629c8 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Wed, 22 Jan 2020 10:02:30 -0800 Subject: [PATCH] Update to flow-bin@0.89 (#17842) --- package.json | 2 +- packages/react-cache/src/LRU.js | 2 +- .../src/client/ReactDOMHostConfig.js | 4 +- .../events/src/dom/PressLegacy.js | 2 + .../src/ReactFabricHostConfig.js | 16 +++--- .../src/ReactNativeHostConfig.js | 14 +++--- .../src/ReactTestHostConfig.js | 6 ++- packages/react/src/ReactHooks.js | 50 +++++++++++-------- scripts/flow/config/flowconfig | 2 +- scripts/flow/environment.js | 4 ++ yarn.lock | 8 +-- 11 files changed, 63 insertions(+), 47 deletions(-) diff --git a/package.json b/package.json index 4d03d25e5f731..c3b1a6d164716 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "eslint-plugin-react-internal": "link:./scripts/eslint-rules", "fbjs-scripts": "^0.8.3", "filesize": "^3.5.6", - "flow-bin": "^0.84.0", + "flow-bin": "0.89", "glob": "^6.0.4", "glob-stream": "^6.1.0", "google-closure-compiler": "20190301.0.0", diff --git a/packages/react-cache/src/LRU.js b/packages/react-cache/src/LRU.js index 0b150dee7c27b..5046b3f2bc9fe 100644 --- a/packages/react-cache/src/LRU.js +++ b/packages/react-cache/src/LRU.js @@ -77,7 +77,7 @@ export function createLRU(limit: number) { } } - function add(value: T, onDelete: () => mixed): Entry { + function add(value: Object, onDelete: () => mixed): Entry { const entry = { value, onDelete, diff --git a/packages/react-dom/src/client/ReactDOMHostConfig.js b/packages/react-dom/src/client/ReactDOMHostConfig.js index e055b6b983766..393f9f033f72a 100644 --- a/packages/react-dom/src/client/ReactDOMHostConfig.js +++ b/packages/react-dom/src/client/ReactDOMHostConfig.js @@ -350,9 +350,9 @@ export const warnsIfNotActing = true; // This initialization code may run even on server environments // if a component just imports ReactDOM (e.g. for findDOMNode). // Some environments might not have setTimeout or clearTimeout. -export const scheduleTimeout = +export const scheduleTimeout: any = typeof setTimeout === 'function' ? setTimeout : (undefined: any); -export const cancelTimeout = +export const cancelTimeout: any = typeof clearTimeout === 'function' ? clearTimeout : (undefined: any); export const noTimeout = -1; diff --git a/packages/react-interactions/events/src/dom/PressLegacy.js b/packages/react-interactions/events/src/dom/PressLegacy.js index ac19d3900a0cb..c81bd3de9a5ff 100644 --- a/packages/react-interactions/events/src/dom/PressLegacy.js +++ b/packages/react-interactions/events/src/dom/PressLegacy.js @@ -777,6 +777,7 @@ const pressResponderImpl = { // Determine whether to call preventDefault on subsequent native events. if ( + target !== null && context.isTargetWithinResponder(target) && context.isTargetWithinHostComponent(target, 'a') ) { @@ -808,6 +809,7 @@ const pressResponderImpl = { if ( !isKeyboardEvent && pressTarget !== null && + target !== null && !targetIsDocument(pressTarget) ) { if ( diff --git a/packages/react-native-renderer/src/ReactFabricHostConfig.js b/packages/react-native-renderer/src/ReactFabricHostConfig.js index da50bebe7b9b0..959860bcf2cbb 100644 --- a/packages/react-native-renderer/src/ReactFabricHostConfig.js +++ b/packages/react-native-renderer/src/ReactFabricHostConfig.js @@ -436,34 +436,34 @@ export function DEPRECATED_unmountResponderInstance( throw new Error('Not yet implemented.'); } -export function getFundamentalComponentInstance(fundamentalInstance) { +export function getFundamentalComponentInstance(fundamentalInstance: any) { throw new Error('Not yet implemented.'); } -export function mountFundamentalComponent(fundamentalInstance) { +export function mountFundamentalComponent(fundamentalInstance: any) { throw new Error('Not yet implemented.'); } -export function shouldUpdateFundamentalComponent(fundamentalInstance) { +export function shouldUpdateFundamentalComponent(fundamentalInstance: any) { throw new Error('Not yet implemented.'); } -export function updateFundamentalComponent(fundamentalInstance) { +export function updateFundamentalComponent(fundamentalInstance: any) { throw new Error('Not yet implemented.'); } -export function unmountFundamentalComponent(fundamentalInstance) { +export function unmountFundamentalComponent(fundamentalInstance: any) { throw new Error('Not yet implemented.'); } -export function cloneFundamentalInstance(fundamentalInstance) { +export function cloneFundamentalInstance(fundamentalInstance: any) { throw new Error('Not yet implemented.'); } -export function getInstanceFromNode(node) { +export function getInstanceFromNode(node: any) { throw new Error('Not yet implemented.'); } -export function beforeRemoveInstance(instance) { +export function beforeRemoveInstance(instance: any) { // noop } diff --git a/packages/react-native-renderer/src/ReactNativeHostConfig.js b/packages/react-native-renderer/src/ReactNativeHostConfig.js index e97aa961f0c73..e91c16a4909dc 100644 --- a/packages/react-native-renderer/src/ReactNativeHostConfig.js +++ b/packages/react-native-renderer/src/ReactNativeHostConfig.js @@ -493,30 +493,30 @@ export function DEPRECATED_unmountResponderInstance( throw new Error('Not yet implemented.'); } -export function getFundamentalComponentInstance(fundamentalInstance) { +export function getFundamentalComponentInstance(fundamentalInstance: any) { throw new Error('Not yet implemented.'); } -export function mountFundamentalComponent(fundamentalInstance) { +export function mountFundamentalComponent(fundamentalInstance: any) { throw new Error('Not yet implemented.'); } -export function shouldUpdateFundamentalComponent(fundamentalInstance) { +export function shouldUpdateFundamentalComponent(fundamentalInstance: any) { throw new Error('Not yet implemented.'); } -export function updateFundamentalComponent(fundamentalInstance) { +export function updateFundamentalComponent(fundamentalInstance: any) { throw new Error('Not yet implemented.'); } -export function unmountFundamentalComponent(fundamentalInstance) { +export function unmountFundamentalComponent(fundamentalInstance: any) { throw new Error('Not yet implemented.'); } -export function getInstanceFromNode(node) { +export function getInstanceFromNode(node: any) { throw new Error('Not yet implemented.'); } -export function beforeRemoveInstance(instance) { +export function beforeRemoveInstance(instance: any) { // noop } diff --git a/packages/react-test-renderer/src/ReactTestHostConfig.js b/packages/react-test-renderer/src/ReactTestHostConfig.js index 170cc08f143e7..58ea9749a1a53 100644 --- a/packages/react-test-renderer/src/ReactTestHostConfig.js +++ b/packages/react-test-renderer/src/ReactTestHostConfig.js @@ -316,7 +316,9 @@ export function DEPRECATED_unmountResponderInstance( // noop } -export function getFundamentalComponentInstance(fundamentalInstance): Instance { +export function getFundamentalComponentInstance( + fundamentalInstance: ReactFundamentalComponentInstance, +): Instance { const {impl, props, state} = fundamentalInstance; return impl.getInstance(null, props, state); } @@ -370,6 +372,6 @@ export function getInstanceFromNode(mockNode: Object) { return null; } -export function beforeRemoveInstance(instance) { +export function beforeRemoveInstance(instance: any) { // noop } diff --git a/packages/react/src/ReactHooks.js b/packages/react/src/ReactHooks.js index 3e28896f2bb89..c725b0e7c54e0 100644 --- a/packages/react/src/ReactHooks.js +++ b/packages/react/src/ReactHooks.js @@ -17,6 +17,9 @@ import {REACT_RESPONDER_TYPE} from 'shared/ReactSymbols'; import ReactCurrentDispatcher from './ReactCurrentDispatcher'; +type BasicStateAction = (S => S) | S; +type Dispatch = A => void; + function resolveDispatcher() { const dispatcher = ReactCurrentDispatcher.current; invariant( @@ -72,7 +75,9 @@ export function useContext( return dispatcher.useContext(Context, unstable_observedBits); } -export function useState(initialState: (() => S) | S) { +export function useState( + initialState: (() => S) | S, +): [S, Dispatch>] { const dispatcher = resolveDispatcher(); return dispatcher.useState(initialState); } @@ -81,7 +86,7 @@ export function useReducer( reducer: (S, A) => S, initialArg: I, init?: I => S, -) { +): [S, Dispatch] { const dispatcher = resolveDispatcher(); return dispatcher.useReducer(reducer, initialArg, init); } @@ -93,46 +98,49 @@ export function useRef(initialValue: T): {|current: T|} { export function useEffect( create: () => (() => void) | void, - inputs: Array | void | null, -) { + deps: Array | void | null, +): void { const dispatcher = resolveDispatcher(); - return dispatcher.useEffect(create, inputs); + return dispatcher.useEffect(create, deps); } export function useLayoutEffect( create: () => (() => void) | void, - inputs: Array | void | null, -) { + deps: Array | void | null, +): void { const dispatcher = resolveDispatcher(); - return dispatcher.useLayoutEffect(create, inputs); + return dispatcher.useLayoutEffect(create, deps); } -export function useCallback( - callback: () => mixed, - inputs: Array | void | null, -) { +export function useCallback( + callback: T, + deps: Array | void | null, +): T { const dispatcher = resolveDispatcher(); - return dispatcher.useCallback(callback, inputs); + return dispatcher.useCallback(callback, deps); } -export function useMemo( - create: () => mixed, - inputs: Array | void | null, -) { +export function useMemo( + create: () => T, + deps: Array | void | null, +): T { const dispatcher = resolveDispatcher(); - return dispatcher.useMemo(create, inputs); + return dispatcher.useMemo(create, deps); } export function useImperativeHandle( ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void, create: () => T, - inputs: Array | void | null, + deps: Array | void | null, ): void { const dispatcher = resolveDispatcher(); - return dispatcher.useImperativeHandle(ref, create, inputs); + return dispatcher.useImperativeHandle(ref, create, deps); } -export function useDebugValue(value: any, formatterFn: ?(value: any) => any) { +export function useDebugValue( + value: T, + formatterFn: ?(value: T) => mixed, +): void { if (__DEV__) { const dispatcher = resolveDispatcher(); return dispatcher.useDebugValue(value, formatterFn); diff --git a/scripts/flow/config/flowconfig b/scripts/flow/config/flowconfig index a82f8cd4bdda0..014b3941cd38e 100644 --- a/scripts/flow/config/flowconfig +++ b/scripts/flow/config/flowconfig @@ -50,4 +50,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError [version] -^0.84.0 \ No newline at end of file +^0.89.0 diff --git a/scripts/flow/environment.js b/scripts/flow/environment.js index 8d3580a215ac3..524cae905bc2e 100644 --- a/scripts/flow/environment.js +++ b/scripts/flow/environment.js @@ -17,6 +17,10 @@ declare var __REACT_DEVTOOLS_GLOBAL_HOOK__: any; /*?{ inject: ?((stuff: Object) => void) };*/ +declare module 'create-react-class' { + declare var exports: React$CreateClass; +} + declare var trustedTypes: {| isHTML: (value: any) => boolean, isScript: (value: any) => boolean, diff --git a/yarn.lock b/yarn.lock index 2f4f3f6aa3e86..283aa30a1ab74 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5725,10 +5725,10 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.1.tgz#69e57caa8f0eacbc281d2e2cb458d46fdb449e08" integrity sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg== -flow-bin@^0.84.0: - version "0.84.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.84.0.tgz#4cb2364c750fb37a7840524fa62456b53f64cdcb" - integrity sha512-ocji8eEYp+YfICsm+F6cIHUcD7v5sb0/ADEXm6gyUKdjQzmSckMrPUdZtyfP973t3YGHKliUMxMvIBHyR5LbXQ== +flow-bin@0.89: + version "0.89.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.89.0.tgz#6bd29c2af7e0f429797f820662f33749105c32fa" + integrity sha512-DkO4PsXYrl53V6G5+t5HbRMC5ajYUQej2LEGPUZ+j9okTb41Sn5j9vfxsCpXMEAslYnQoysHhYu4GUZsQX/DrQ== fluent-syntax@0.13.0: version "0.13.0"