Skip to content

Commit 5f99a48

Browse files
iamdustanacdlite
authored andcommitted
Update to Flow 0.47 (facebook#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
1 parent 9dcc60a commit 5f99a48

File tree

10 files changed

+34
-26
lines changed

10 files changed

+34
-26
lines changed

.flowconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
3838
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
3939

4040
[version]
41-
^0.45.0
41+
^0.47.0

flow/react-native-host-hooks.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ declare module 'deepFreezeAndThrowOnMutationInDev' {
2020
declare module 'flattenStyle' { }
2121
declare module 'InitializeCore' { }
2222
declare module 'RCTEventEmitter' {
23-
declare function register() : void;
23+
declare function register(mixed) : void;
2424
}
2525
declare module 'TextInputState' {
2626
declare function blurTextInput(object : any) : void;
@@ -49,11 +49,19 @@ declare module 'UIManager' {
4949
addAtIndices : Array<number>,
5050
removeAtIndices : Array<number>
5151
) : 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;
5765
declare function replaceExistingNonRootView() : void;
5866
declare function setChildren(
5967
containerTag : number,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"fbjs": "^0.8.9",
5757
"fbjs-scripts": "^0.6.0",
5858
"filesize": "^3.5.6",
59-
"flow-bin": "^0.45.0",
59+
"flow-bin": "^0.47.0",
6060
"git-branch": "^0.3.0",
6161
"glob": "^6.0.4",
6262
"glob-stream": "^6.1.0",

src/renderers/dom/fiber/ReactDOMFiberComponent.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ var ReactDOMFiberComponent = {
303303
},
304304

305305
createElement(
306-
type: string,
306+
type: *,
307307
props: Object,
308308
rootContainerElement: Element | Document,
309309
parentNamespace: string,
@@ -341,6 +341,7 @@ var ReactDOMFiberComponent = {
341341
var firstChild = ((div.firstChild: any): HTMLScriptElement);
342342
domElement = div.removeChild(firstChild);
343343
} else if (props.is) {
344+
// $FlowIssue `createElement` should be updated for Web Components
344345
domElement = ownerDocument.createElement(type, {is: props.is});
345346
} else {
346347
// Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.

src/renderers/dom/fiber/wrappers/ReactDOMFiberInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ var ReactDOMInput = {
201201
// Note: IE9 reports a number inputs as 'text', so check props instead.
202202
} else if (props.type === 'number') {
203203
// Simulate `input.valueAsNumber`. IE9 does not support it
204-
var valueAsNumber = parseFloat(node.value, 10) || 0;
204+
var valueAsNumber = parseFloat(node.value) || 0;
205205

206206
// eslint-disable-next-line
207207
if (value != valueAsNumber) {

src/renderers/shared/fiber/ReactFiberBeginWork.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if (__DEV__) {
6666
module.exports = function<T, P, I, TI, PI, C, CX, PL>(
6767
config: HostConfig<T, P, I, TI, PI, C, CX, PL>,
6868
hostContext: HostContext<C, CX>,
69-
hydrationContext: HydrationContext<I, TI>,
69+
hydrationContext: HydrationContext<I, TI, C>,
7070
scheduleUpdate: (fiber: Fiber, priorityLevel: PriorityLevel) => void,
7171
getPriorityContext: (fiber: Fiber, forceAsync: boolean) => PriorityLevel,
7272
) {

src/renderers/shared/fiber/ReactFiberCompleteWork.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var invariant = require('fbjs/lib/invariant');
4747
module.exports = function<T, P, I, TI, PI, C, CX, PL>(
4848
config: HostConfig<T, P, I, TI, PI, C, CX, PL>,
4949
hostContext: HostContext<C, CX>,
50-
hydrationContext: HydrationContext<I, TI>,
50+
hydrationContext: HydrationContext<I, TI, C>,
5151
) {
5252
const {
5353
createInstance,
@@ -340,10 +340,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
340340
let textInstance;
341341
let wasHydrated = popHydrationState(workInProgress);
342342
if (wasHydrated) {
343-
textInstance = hydrateHostTextInstance(
344-
workInProgress,
345-
rootContainerInstance,
346-
);
343+
textInstance = hydrateHostTextInstance(workInProgress);
347344
} else {
348345
textInstance = createTextInstance(
349346
newText,

src/renderers/shared/fiber/ReactFiberHydrationContext.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ const {Deletion, Placement} = require('ReactTypeOfSideEffect');
2222

2323
const {createFiberFromHostInstanceForDeletion} = require('ReactFiber');
2424

25-
export type HydrationContext<I, TI> = {
25+
export type HydrationContext<I, TI, C> = {
2626
enterHydrationState(fiber: Fiber): boolean,
2727
resetHydrationState(): void,
2828
tryToClaimNextHydratableInstance(fiber: Fiber): void,
29-
hydrateHostInstance(fiber: Fiber): I,
29+
hydrateHostInstance(fiber: Fiber, rootContainerInstance: C): I,
3030
hydrateHostTextInstance(fiber: Fiber): TI,
3131
popHydrationState(fiber: Fiber): boolean,
3232
};
3333

3434
module.exports = function<T, P, I, TI, PI, C, CX, PL>(
3535
config: HostConfig<T, P, I, TI, PI, C, CX, PL>,
36-
): HydrationContext<I, TI> {
36+
): HydrationContext<I, TI, C> {
3737
const {
3838
shouldSetTextContent,
3939
canHydrateInstance,
@@ -147,7 +147,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
147147
nextHydratableInstance = getFirstHydratableChild(nextInstance);
148148
}
149149

150-
function hydrateHostInstance(fiber: Fiber, rootContainerInstance: any): I {
150+
function hydrateHostInstance(fiber: Fiber, rootContainerInstance: C): I {
151151
const instance: I = fiber.stateNode;
152152
hydrateInstance(
153153
instance,

src/renderers/shared/fiber/ReactFiberScheduler.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,11 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
146146
config: HostConfig<T, P, I, TI, PI, C, CX, PL>,
147147
) {
148148
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);
152154
const {popHostContainer, popHostContext, resetHostContainer} = hostContext;
153155
const {beginWork, beginFailedWork} = ReactFiberBeginWork(
154156
config,

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,9 +2287,9 @@ flat-cache@^1.2.1:
22872287
graceful-fs "^4.1.2"
22882288
write "^0.2.1"
22892289

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"
22932293

22942294
22952295
version "0.43.0"

0 commit comments

Comments
 (0)