Skip to content

Commit dd5fad2

Browse files
authored
Update Flow to 0.70 (#12875)
* Update Flow to 0.70 * Remove unnecessary condition * Fix wrong assertion * Strict check
1 parent 1300365 commit dd5fad2

File tree

16 files changed

+63
-40
lines changed

16 files changed

+63
-40
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"fbjs": "^0.8.16",
6161
"fbjs-scripts": "^0.6.0",
6262
"filesize": "^3.5.6",
63-
"flow-bin": "^0.61.0",
63+
"flow-bin": "^0.72.0",
6464
"flow-coverage-report": "^0.4.0",
6565
"git-branch": "^0.3.0",
6666
"glob": "^6.0.4",

packages/react-dom/src/client/ReactDOM.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ let didWarnAboutUnstableCreatePortal = false;
5353
if (__DEV__) {
5454
if (
5555
typeof Map !== 'function' ||
56+
// $FlowIssue Flow incorrectly thinks Map has no prototype
5657
Map.prototype == null ||
5758
typeof Map.prototype.forEach !== 'function' ||
5859
typeof Set !== 'function' ||
60+
// $FlowIssue Flow incorrectly thinks Set has no prototype
5961
Set.prototype == null ||
6062
typeof Set.prototype.clear !== 'function' ||
6163
typeof Set.prototype.forEach !== 'function'

packages/react-dom/src/client/ReactDOMFiberComponent.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,11 @@ export function setInitialProperties(
432432
const isCustomComponentTag = isCustomComponent(tag, rawProps);
433433
if (__DEV__) {
434434
validatePropertiesInDevelopment(tag, rawProps);
435-
if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) {
435+
if (
436+
isCustomComponentTag &&
437+
!didWarnShadyDOM &&
438+
(domElement: any).shadyRoot
439+
) {
436440
warning(
437441
false,
438442
'%s is using shady DOM. Using shady DOM with React can ' +
@@ -820,7 +824,11 @@ export function diffHydratedProperties(
820824
suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING] === true;
821825
isCustomComponentTag = isCustomComponent(tag, rawProps);
822826
validatePropertiesInDevelopment(tag, rawProps);
823-
if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) {
827+
if (
828+
isCustomComponentTag &&
829+
!didWarnShadyDOM &&
830+
(domElement: any).shadyRoot
831+
) {
824832
warning(
825833
false,
826834
'%s is using shady DOM. Using shady DOM with React can ' +

packages/react-dom/src/client/ReactDOMHostConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export type Props = {
3030
children?: mixed,
3131
hidden?: boolean,
3232
suppressHydrationWarning?: boolean,
33+
dangerouslySetInnerHTML?: mixed,
3334
};
3435
export type Container = Element | Document;
3536
export type Instance = Element;

packages/react-dom/src/client/inputValueTracking.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,21 @@ function trackValueOnNode(node: any): ?ValueTracker {
6363
// (needed for certain tests that spyOn input values and Safari)
6464
if (
6565
node.hasOwnProperty(valueField) ||
66+
typeof descriptor === 'undefined' ||
6667
typeof descriptor.get !== 'function' ||
6768
typeof descriptor.set !== 'function'
6869
) {
6970
return;
7071
}
71-
72+
const {get, set} = descriptor;
7273
Object.defineProperty(node, valueField, {
7374
configurable: true,
7475
get: function() {
75-
return descriptor.get.call(this);
76+
return get.call(this);
7677
},
7778
set: function(value) {
7879
currentValue = '' + value;
79-
descriptor.set.call(this, value);
80+
set.call(this, value);
8081
},
8182
});
8283
// We could've passed this the first time

packages/react-dom/src/events/TapEventPlugin.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,11 @@ const pointerEvents = [
119119
TOP_POINTER_UP,
120120
];
121121

122-
const dependencies = [TOP_MOUSE_DOWN, TOP_MOUSE_MOVE, TOP_MOUSE_UP].concat(
123-
touchEvents,
124-
pointerEvents,
125-
);
122+
const dependencies: Array<TopLevelType> = [
123+
TOP_MOUSE_DOWN,
124+
TOP_MOUSE_MOVE,
125+
TOP_MOUSE_UP,
126+
].concat(touchEvents, pointerEvents);
126127

127128
const eventTypes = {
128129
touchTap: {

packages/react-native-renderer/src/ReactFabric.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ function findNodeHandle(componentOrHandle: any): ?number {
6363
if (hostInstance == null) {
6464
return hostInstance;
6565
}
66-
if (hostInstance.canonical) {
66+
// TODO: the code is right but the types here are wrong.
67+
// https://github.com/facebook/react/pull/12863
68+
if ((hostInstance: any).canonical) {
6769
// Fabric
68-
return (hostInstance.canonical: any)._nativeTag;
70+
return (hostInstance: any).canonical._nativeTag;
6971
}
7072
return hostInstance._nativeTag;
7173
}

packages/react-native-renderer/src/ReactNativeFrameScheduling.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ function scheduleDeferredCallback(
4949
): number {
5050
// We assume only one callback is scheduled at a time b'c that's how Fiber works.
5151
scheduledCallback = callback;
52-
return setTimeout(setTimeoutCallback, 1);
52+
const timeoutId = setTimeout(setTimeoutCallback, 1);
53+
return (timeoutId: any); // Timeouts are always numbers on RN
5354
}
5455

5556
function cancelDeferredCallback(callbackID: number) {
5657
scheduledCallback = null;
57-
clearTimeout(callbackID);
58+
clearTimeout((callbackID: any)); // Timeouts are always numbers on RN
5859
}
5960

6061
export {now, scheduleDeferredCallback, cancelDeferredCallback};

packages/react-native-renderer/src/ReactNativeRenderer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ function findNodeHandle(componentOrHandle: any): ?number {
6666
if (hostInstance == null) {
6767
return hostInstance;
6868
}
69-
if (hostInstance.canonical) {
69+
if ((hostInstance: any).canonical) {
7070
// Fabric
71-
return (hostInstance.canonical: any)._nativeTag;
71+
return (hostInstance: any).canonical._nativeTag;
7272
}
7373
return hostInstance._nativeTag;
7474
}

packages/react-noop-renderer/src/createReactNoop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import emptyObject from 'fbjs/lib/emptyObject';
2323
import expect from 'expect';
2424

2525
type Container = {rootID: string, children: Array<Instance | TextInstance>};
26-
type Props = {prop: any, hidden?: boolean};
26+
type Props = {prop: any, hidden?: boolean, children?: mixed};
2727
type Instance = {|
2828
type: string,
2929
id: number,

0 commit comments

Comments
 (0)