Update to Flow 0.47 (#9815)
* bump flow to 0.47 * Fix variadic function flow issues in fiber * Fix variadic function flow issues in ReactFiberNative * fix ReactDOM type issues with flow 0.47 * getChildHostContext *does* take an `instance` argument * change recently added anys to mixedies * HydrationContext needs a handle on the rootContainerInstance * prettier
Dustan Kasten committed
Jun 1, 2017 at 15:17 UTC
5f99a482299e516cbdb16e8929d49ec9fdd17dd7
10 files changed
+34
-26
.flowconfig
+1
-1
@@ -38,4 +38,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
38
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
39
40
[version]
41
-^0.45.0
41
+^0.47.0
flow/react-native-host-hooks.js
+14
-6
@@ -20,7 +20,7 @@ declare module 'deepFreezeAndThrowOnMutationInDev' {
20
declare module 'flattenStyle' { }
21
declare module 'InitializeCore' { }
22
declare module 'RCTEventEmitter' {
23
- declare function register() : void;
23
+ declare function register(mixed) : void;
24
}
25
declare module 'TextInputState' {
26
declare function blurTextInput(object : any) : void;
@@ -49,11 +49,19 @@ declare module 'UIManager' {
49
addAtIndices : Array<number>,
50
removeAtIndices : Array<number>
51
) : void;
52
- declare function measure() : void;
53
- declare function measureInWindow() : void;
54
- declare function measureLayout() : void;
55
- declare function removeRootView() : void;
56
- declare function removeSubviewsFromContainerWithID() : void;
52
+ declare function measure(hostComponent: mixed, callback: Function) : void;
53
+ declare function measureInWindow(
54
+ nativeTag : ?number,
55
+ callback : Function
56
+ ) : void;
57
+ declare function measureLayout(
58
+ nativeTag : mixed,
59
+ nativeNode : number,
60
+ onFail : Function,
61
+ onSuccess : Function
62
+ ) : void;
63
+ declare function removeRootView(containerTag : number) : void;
64
+ declare function removeSubviewsFromContainerWithID(containerId : number) : void;
65
declare function replaceExistingNonRootView() : void;
66
declare function setChildren(
67
containerTag : number,
package.json
+1
-1
@@ -56,7 +56,7 @@
56
"fbjs": "^0.8.9",
57
"fbjs-scripts": "^0.6.0",
58
"filesize": "^3.5.6",
59
- "flow-bin": "^0.45.0",
59
+ "flow-bin": "^0.47.0",
60
"git-branch": "^0.3.0",
61
"glob": "^6.0.4",
62
"glob-stream": "^6.1.0",
src/renderers/dom/fiber/ReactDOMFiberComponent.js
+2
-1
@@ -303,7 +303,7 @@ var ReactDOMFiberComponent = {
303
},
304
305
createElement(
306
- type: string,
306
+ type: *,
307
props: Object,
308
rootContainerElement: Element | Document,
309
parentNamespace: string,
@@ -341,6 +341,7 @@ var ReactDOMFiberComponent = {
341
var firstChild = ((div.firstChild: any): HTMLScriptElement);
342
domElement = div.removeChild(firstChild);
343
} else if (props.is) {
344
+ // $FlowIssue `createElement` should be updated for Web Components
345
domElement = ownerDocument.createElement(type, {is: props.is});
346
} else {
347
// Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.
src/renderers/dom/fiber/wrappers/ReactDOMFiberInput.js
+1
-1
@@ -201,7 +201,7 @@ var ReactDOMInput = {
201
// Note: IE9 reports a number inputs as 'text', so check props instead.
202
} else if (props.type === 'number') {
203
// Simulate `input.valueAsNumber`. IE9 does not support it
204
- var valueAsNumber = parseFloat(node.value, 10) || 0;
204
+ var valueAsNumber = parseFloat(node.value) || 0;
205
206
// eslint-disable-next-line
207
if (value != valueAsNumber) {
src/renderers/shared/fiber/ReactFiberBeginWork.js
+1
-1
@@ -66,7 +66,7 @@ if (__DEV__) {
66
module.exports = function<T, P, I, TI, PI, C, CX, PL>(
67
config: HostConfig<T, P, I, TI, PI, C, CX, PL>,
68
hostContext: HostContext<C, CX>,
69
- hydrationContext: HydrationContext<I, TI>,
69
+ hydrationContext: HydrationContext<I, TI, C>,
70
scheduleUpdate: (fiber: Fiber, priorityLevel: PriorityLevel) => void,
71
getPriorityContext: (fiber: Fiber, forceAsync: boolean) => PriorityLevel,
72
) {
src/renderers/shared/fiber/ReactFiberCompleteWork.js
+2
-5
@@ -47,7 +47,7 @@ var invariant = require('fbjs/lib/invariant');
47
module.exports = function<T, P, I, TI, PI, C, CX, PL>(
48
config: HostConfig<T, P, I, TI, PI, C, CX, PL>,
49
hostContext: HostContext<C, CX>,
50
- hydrationContext: HydrationContext<I, TI>,
50
+ hydrationContext: HydrationContext<I, TI, C>,
51
) {
52
const {
53
createInstance,
@@ -340,10 +340,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
340
let textInstance;
341
let wasHydrated = popHydrationState(workInProgress);
342
if (wasHydrated) {
343
- textInstance = hydrateHostTextInstance(
344
- workInProgress,
345
- rootContainerInstance,
346
- );
343
+ textInstance = hydrateHostTextInstance(workInProgress);
344
} else {
345
textInstance = createTextInstance(
346
newText,
src/renderers/shared/fiber/ReactFiberHydrationContext.js
+4
-4
@@ -22,18 +22,18 @@ const {Deletion, Placement} = require('ReactTypeOfSideEffect');
22
23
const {createFiberFromHostInstanceForDeletion} = require('ReactFiber');
24
25
-export type HydrationContext<I, TI> = {
25
+export type HydrationContext<I, TI, C> = {
26
enterHydrationState(fiber: Fiber): boolean,
27
resetHydrationState(): void,
28
tryToClaimNextHydratableInstance(fiber: Fiber): void,
29
- hydrateHostInstance(fiber: Fiber): I,
29
+ hydrateHostInstance(fiber: Fiber, rootContainerInstance: C): I,
30
hydrateHostTextInstance(fiber: Fiber): TI,
31
popHydrationState(fiber: Fiber): boolean,
32
};
33
34
module.exports = function<T, P, I, TI, PI, C, CX, PL>(
35
config: HostConfig<T, P, I, TI, PI, C, CX, PL>,
36
-): HydrationContext<I, TI> {
36
+): HydrationContext<I, TI, C> {
37
const {
38
shouldSetTextContent,
39
canHydrateInstance,
@@ -147,7 +147,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
147
nextHydratableInstance = getFirstHydratableChild(nextInstance);
148
}
149
150
- function hydrateHostInstance(fiber: Fiber, rootContainerInstance: any): I {
150
+ function hydrateHostInstance(fiber: Fiber, rootContainerInstance: C): I {
151
const instance: I = fiber.stateNode;
152
hydrateInstance(
153
instance,
src/renderers/shared/fiber/ReactFiberScheduler.js
+5
-3
@@ -146,9 +146,11 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
146
config: HostConfig<T, P, I, TI, PI, C, CX, PL>,
147
) {
148
const hostContext = ReactFiberHostContext(config);
149
- const hydrationContext: HydrationContext<I, TI> = ReactFiberHydrationContext(
150
- config,
151
- );
149
+ const hydrationContext: HydrationContext<
150
+ I,
151
+ TI,
152
+ C
153
+ > = ReactFiberHydrationContext(config);
154
const {popHostContainer, popHostContext, resetHostContainer} = hostContext;
155
const {beginWork, beginFailedWork} = ReactFiberBeginWork(
156
config,
yarn.lock
+3
-3
@@ -2287,9 +2287,9 @@ flat-cache@^1.2.1:
2287
graceful-fs "^4.1.2"
2288
write "^0.2.1"
2289
2290
-flow-bin@^0.45.0:
2291
- version "0.45.0"
2292
- resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.45.0.tgz#009dd0f577a3f665c74ca8be827ae8c2dd8fd6b5"
2290
+flow-bin@^0.47.0:
2291
+ version "0.47.0"
2292
+ resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.47.0.tgz#a2a08ab3e0d1f1cb57d17e27b30b118b62fda367"
2293
2294
flow-parser@0.43.0:
2295
version "0.43.0"