Skip to content

Commit

Permalink
Update to Flow 0.47 (facebook#9815)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
iamdustan authored and acdlite committed Jun 1, 2017
1 parent 9dcc60a commit 5f99a48
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

[version]
^0.45.0
^0.47.0
20 changes: 14 additions & 6 deletions flow/react-native-host-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ declare module 'deepFreezeAndThrowOnMutationInDev' {
declare module 'flattenStyle' { }
declare module 'InitializeCore' { }
declare module 'RCTEventEmitter' {
declare function register() : void;
declare function register(mixed) : void;
}
declare module 'TextInputState' {
declare function blurTextInput(object : any) : void;
Expand Down Expand Up @@ -49,11 +49,19 @@ declare module 'UIManager' {
addAtIndices : Array<number>,
removeAtIndices : Array<number>
) : void;
declare function measure() : void;
declare function measureInWindow() : void;
declare function measureLayout() : void;
declare function removeRootView() : void;
declare function removeSubviewsFromContainerWithID() : void;
declare function measure(hostComponent: mixed, callback: Function) : void;
declare function measureInWindow(
nativeTag : ?number,
callback : Function
) : void;
declare function measureLayout(
nativeTag : mixed,
nativeNode : number,
onFail : Function,
onSuccess : Function
) : void;
declare function removeRootView(containerTag : number) : void;
declare function removeSubviewsFromContainerWithID(containerId : number) : void;
declare function replaceExistingNonRootView() : void;
declare function setChildren(
containerTag : number,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"fbjs": "^0.8.9",
"fbjs-scripts": "^0.6.0",
"filesize": "^3.5.6",
"flow-bin": "^0.45.0",
"flow-bin": "^0.47.0",
"git-branch": "^0.3.0",
"glob": "^6.0.4",
"glob-stream": "^6.1.0",
Expand Down
3 changes: 2 additions & 1 deletion src/renderers/dom/fiber/ReactDOMFiberComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ var ReactDOMFiberComponent = {
},

createElement(
type: string,
type: *,
props: Object,
rootContainerElement: Element | Document,
parentNamespace: string,
Expand Down Expand Up @@ -341,6 +341,7 @@ var ReactDOMFiberComponent = {
var firstChild = ((div.firstChild: any): HTMLScriptElement);
domElement = div.removeChild(firstChild);
} else if (props.is) {
// $FlowIssue `createElement` should be updated for Web Components
domElement = ownerDocument.createElement(type, {is: props.is});
} else {
// Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/dom/fiber/wrappers/ReactDOMFiberInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ var ReactDOMInput = {
// Note: IE9 reports a number inputs as 'text', so check props instead.
} else if (props.type === 'number') {
// Simulate `input.valueAsNumber`. IE9 does not support it
var valueAsNumber = parseFloat(node.value, 10) || 0;
var valueAsNumber = parseFloat(node.value) || 0;

// eslint-disable-next-line
if (value != valueAsNumber) {
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/shared/fiber/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if (__DEV__) {
module.exports = function<T, P, I, TI, PI, C, CX, PL>(
config: HostConfig<T, P, I, TI, PI, C, CX, PL>,
hostContext: HostContext<C, CX>,
hydrationContext: HydrationContext<I, TI>,
hydrationContext: HydrationContext<I, TI, C>,
scheduleUpdate: (fiber: Fiber, priorityLevel: PriorityLevel) => void,
getPriorityContext: (fiber: Fiber, forceAsync: boolean) => PriorityLevel,
) {
Expand Down
7 changes: 2 additions & 5 deletions src/renderers/shared/fiber/ReactFiberCompleteWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var invariant = require('fbjs/lib/invariant');
module.exports = function<T, P, I, TI, PI, C, CX, PL>(
config: HostConfig<T, P, I, TI, PI, C, CX, PL>,
hostContext: HostContext<C, CX>,
hydrationContext: HydrationContext<I, TI>,
hydrationContext: HydrationContext<I, TI, C>,
) {
const {
createInstance,
Expand Down Expand Up @@ -340,10 +340,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
let textInstance;
let wasHydrated = popHydrationState(workInProgress);
if (wasHydrated) {
textInstance = hydrateHostTextInstance(
workInProgress,
rootContainerInstance,
);
textInstance = hydrateHostTextInstance(workInProgress);
} else {
textInstance = createTextInstance(
newText,
Expand Down
8 changes: 4 additions & 4 deletions src/renderers/shared/fiber/ReactFiberHydrationContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ const {Deletion, Placement} = require('ReactTypeOfSideEffect');

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

export type HydrationContext<I, TI> = {
export type HydrationContext<I, TI, C> = {
enterHydrationState(fiber: Fiber): boolean,
resetHydrationState(): void,
tryToClaimNextHydratableInstance(fiber: Fiber): void,
hydrateHostInstance(fiber: Fiber): I,
hydrateHostInstance(fiber: Fiber, rootContainerInstance: C): I,
hydrateHostTextInstance(fiber: Fiber): TI,
popHydrationState(fiber: Fiber): boolean,
};

module.exports = function<T, P, I, TI, PI, C, CX, PL>(
config: HostConfig<T, P, I, TI, PI, C, CX, PL>,
): HydrationContext<I, TI> {
): HydrationContext<I, TI, C> {
const {
shouldSetTextContent,
canHydrateInstance,
Expand Down Expand Up @@ -147,7 +147,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
nextHydratableInstance = getFirstHydratableChild(nextInstance);
}

function hydrateHostInstance(fiber: Fiber, rootContainerInstance: any): I {
function hydrateHostInstance(fiber: Fiber, rootContainerInstance: C): I {
const instance: I = fiber.stateNode;
hydrateInstance(
instance,
Expand Down
8 changes: 5 additions & 3 deletions src/renderers/shared/fiber/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,11 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
config: HostConfig<T, P, I, TI, PI, C, CX, PL>,
) {
const hostContext = ReactFiberHostContext(config);
const hydrationContext: HydrationContext<I, TI> = ReactFiberHydrationContext(
config,
);
const hydrationContext: HydrationContext<
I,
TI,
C
> = ReactFiberHydrationContext(config);
const {popHostContainer, popHostContext, resetHostContainer} = hostContext;
const {beginWork, beginFailedWork} = ReactFiberBeginWork(
config,
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2287,9 +2287,9 @@ flat-cache@^1.2.1:
graceful-fs "^4.1.2"
write "^0.2.1"

flow-bin@^0.45.0:
version "0.45.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.45.0.tgz#009dd0f577a3f665c74ca8be827ae8c2dd8fd6b5"
flow-bin@^0.47.0:
version "0.47.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.47.0.tgz#a2a08ab3e0d1f1cb57d17e27b30b118b62fda367"

flow-parser@0.43.0:
version "0.43.0"
Expand Down

0 comments on commit 5f99a48

Please sign in to comment.