Skip to content

Commit

Permalink
Update Flow and fix issues (facebook#8006)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored and acusti committed Mar 15, 2017
1 parent 14ae463 commit 3c7873e
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 22 deletions.
8 changes: 4 additions & 4 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[include]

[libs]
./node_modules/fbjs/flow/lib
./node_modules/fbjs/flow/lib/dev.js
./flow

[options]
Expand All @@ -29,10 +29,10 @@ suppress_type=$FlowFixMe
suppress_type=$FixMe
suppress_type=$FlowExpectedError

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-1]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*www[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-1]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*www[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*www[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*www[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

[version]
^0.31.0
^0.33.0
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"eslint": "1.10.3",
"eslint-plugin-react": "4.1.0",
"eslint-plugin-react-internal": "file:eslint-rules",
"fbjs": "^0.8.4",
"fbjs": "^0.8.5",
"fbjs-scripts": "^0.6.0",
"flow-bin": "^0.31.0",
"flow-bin": "^0.33.0",
"glob": "^6.0.1",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
Expand Down
10 changes: 6 additions & 4 deletions src/renderers/dom/fiber/ReactDOMFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ var DOMRenderer = ReactFiberReconciler({
createInstance(type : string, props : Props, children : HostChildren<Instance | TextInstance>) : Instance {
const domElement = document.createElement(type);
recursivelyAppendChildren(domElement, children);
if (typeof props.children === 'string' ||
typeof props.children === 'number') {
if (typeof props.children === 'string') {
domElement.textContent = props.children;
} else if (typeof props.children === 'number') {
domElement.textContent = props.children.toString();
}
return domElement;
},
Expand All @@ -70,9 +71,10 @@ var DOMRenderer = ReactFiberReconciler({
},

commitUpdate(domElement : Instance, oldProps : Props, newProps : Props) : void {
if (typeof newProps.children === 'string' ||
typeof newProps.children === 'number') {
if (typeof newProps.children === 'string') {
domElement.textContent = newProps.children;
} else if (typeof newProps.children === 'number') {
domElement.textContent = newProps.children.toString();
}
},

Expand Down
2 changes: 1 addition & 1 deletion src/renderers/native/NativeMethodsMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ function mountSafeCallback(
callback: ?Function
): any {
return function() {
if (!callback || (context.isMounted && !context.isMounted())) {
if (!callback || (typeof context.isMounted === 'function' && !context.isMounted())) {
return undefined;
}
return callback.apply(context, arguments);
Expand Down
1 change: 0 additions & 1 deletion src/renderers/shared/ReactDebugTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ function resumeCurrentLifeCycleTimer() {

var lastMarkTimeStamp = 0;
var canUsePerformanceMeasure: boolean =
// $FlowFixMe https://github.com/facebook/flow/issues/2345
typeof performance !== 'undefined' &&
typeof performance.mark === 'function' &&
typeof performance.clearMarks === 'function' &&
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 @@ -369,7 +369,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>, s
// next one immediately.
return workInProgress.child;
case HostComponent:
if (workInProgress.stateNode && config.beginUpdate) {
if (workInProgress.stateNode && typeof config.beginUpdate === 'function') {
config.beginUpdate(workInProgress.stateNode);
}
return updateHostComponent(current, workInProgress);
Expand Down
15 changes: 10 additions & 5 deletions src/renderers/shared/stack/reconciler/ReactInstanceType.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@

'use strict';

import type {ReactElement} from 'ReactElementType';

export type DebugID = number;

export type ReactInstance = {
// ReactCompositeComponent
// Shared
mountComponent: any,
unmountComponent: any,
receiveComponent: any,
getName: () => string,
getPublicInstance: any,
_currentElement: ReactElement,

// ReactCompositeComponent
performInitialMountWithErrorHandling: any,
performInitialMount: any,
getHostNode: any,
unmountComponent: any,
receiveComponent: any,
performUpdateIfNecessary: any,
updateComponent: any,
attachRef: (ref: string, component: ReactInstance) => void,
detachRef: (ref: string) => void,
getName: () => string,
getPublicInstance: any,
_rootNodeID: number,

// ReactDOMComponent
Expand Down
1 change: 0 additions & 1 deletion src/renderers/shared/utils/ReactErrorUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ if (__DEV__) {
var evtType = `react-${name}`;
fakeNode.addEventListener(evtType, boundFunc, false);
var evt = document.createEvent('Event');
// $FlowFixMe https://github.com/facebook/flow/issues/2336
evt.initEvent(evtType, false, false);
fakeNode.dispatchEvent(evt);
fakeNode.removeEventListener(evtType, boundFunc, false);
Expand Down
4 changes: 1 addition & 3 deletions src/renderers/testing/ReactTestMount.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ var getHostComponentFromComposite = require('getHostComponentFromComposite');
var instantiateReactComponent = require('instantiateReactComponent');
var invariant = require('invariant');

import type { ReactElement } from 'ReactElementType';

export type TestRendererOptions = {
createNodeMock: (element: ReactElement) => any,
createNodeMock: (element: ReactElement<any>) => any,
};

var defaultTestOptions = {
Expand Down

0 comments on commit 3c7873e

Please sign in to comment.