Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = {
'no-for-of-loops',
'react',
'react-internal',
'flowtype',
],

parser: 'espree',
Expand Down Expand Up @@ -89,6 +90,7 @@ module.exports = {
'react-internal/no-primitive-constructors': ERROR,
'react-internal/no-to-warn-dev-within-to-throw': ERROR,
'react-internal/warning-and-invariant-args': ERROR,
'flowtype/no-types-missing-file-annotation': ERROR,
},

overrides: [
Expand Down
26 changes: 21 additions & 5 deletions packages/events/EventPropagators.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

import type {Fiber} from 'react-reconciler/src/ReactFiber';
import type {
ReactSyntheticEvent,
DispatchConfig,
} from './ReactSyntheticEventType';
import {
getParentInstance,
traverseTwoPhase,
Expand Down Expand Up @@ -106,24 +113,33 @@ function accumulateDispatches(inst, ignoredDirection, event) {
* `dispatchMarker`.
* @param {SyntheticEvent} event
*/
function accumulateDirectDispatchesSingle(event) {
function accumulateDirectDispatchesSingle(event: ReactSyntheticEvent) {
if (event && event.dispatchConfig.registrationName) {
accumulateDispatches(event._targetInst, null, event);
}
}

export function accumulateTwoPhaseDispatches(events) {
export function accumulateTwoPhaseDispatches(
events: Array<ReactSyntheticEvent>,
) {
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
}

export function accumulateTwoPhaseDispatchesSkipTarget(events) {
export function accumulateTwoPhaseDispatchesSkipTarget(
events: Array<ReactSyntheticEvent>,
) {
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
}

export function accumulateEnterLeaveDispatches(leave, enter, from, to) {
export function accumulateEnterLeaveDispatches(
leave: DispatchConfig,
enter: DispatchConfig,
from: Fiber,
to: Fiber,
) {
traverseEnterLeave(from, to, accumulateDispatches, leave, enter);
}

export function accumulateDirectDispatches(events) {
export function accumulateDirectDispatches(events: Array<ReactSyntheticEvent>) {
forEachAccumulated(events, accumulateDirectDispatchesSingle);
}
3 changes: 3 additions & 0 deletions packages/events/ReactSyntheticEventType.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ export type ReactSyntheticEvent = {
nativeEventTarget: EventTarget,
) => ReactSyntheticEvent,
isPersistent: () => boolean,
_targetInst: Fiber,
_dispatchListeners: ReactSyntheticEvent | Array<ReactSyntheticEvent>,
_dispatchInstances: Fiber | Array<Fiber>,
} & SyntheticEvent<>;
2 changes: 1 addition & 1 deletion packages/react-art/src/ReactARTHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,6 @@ export function unhideInstance(instance, props) {
}
}

export function unhideTextInstance(textInstance, text): void {
export function unhideTextInstance(textInstance, text) {
// Noop
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
* @flow
*/

'use strict';
Expand Down
37 changes: 2 additions & 35 deletions packages/react-dom/src/__tests__/ReactCompositeComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

'use strict';

import shallowEqual from 'shared/shallowEqual';

let ChildUpdates;
let MorphingComponent;
let React;
Expand All @@ -19,41 +21,6 @@ let ReactTestUtils;
let PropTypes;

describe('ReactCompositeComponent', () => {
const hasOwnProperty = Object.prototype.hasOwnProperty;

/**
* Performs equality by iterating through keys on an object and returning false
* when any key has values which are not strictly equal between the arguments.
* Returns true when the values of all keys are strictly equal.
*/
function shallowEqual(objA: mixed, objB: mixed): boolean {
if (Object.is(objA, objB)) {
return true;
}
if (
typeof objA !== 'object' ||
objA === null ||
typeof objB !== 'object' ||
objB === null
) {
return false;
}
const keysA = Object.keys(objA);
const keysB = Object.keys(objB);
if (keysA.length !== keysB.length) {
return false;
}
for (let i = 0; i < keysA.length; i++) {
if (
!hasOwnProperty.call(objB, keysA[i]) ||
!Object.is(objA[keysA[i]], objB[keysA[i]])
) {
return false;
}
}
return true;
}

function shallowCompare(instance, nextProps, nextState) {
return (
!shallowEqual(instance.props, nextProps) ||
Expand Down
2 changes: 2 additions & 0 deletions packages/react-dom/src/events/BeforeInputEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

import type {TopLevelType} from 'events/TopLevelEventTypes';
Expand Down
2 changes: 2 additions & 0 deletions packages/react-dom/src/shared/DOMNamespaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
Expand Down
6 changes: 4 additions & 2 deletions packages/react-dom/src/shared/assertValidProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

import invariant from 'shared/invariant';
Expand Down Expand Up @@ -31,7 +33,7 @@ function assertValidProps(tag: string, props: ?Object) {
'%s is a void element tag and must neither have `children` nor ' +
'use `dangerouslySetInnerHTML`.%s',
tag,
__DEV__ ? ReactDebugCurrentFrame.getStackAddendum() : '',
__DEV__ && ReactDebugCurrentFrame ? ReactDebugCurrentFrame.getStackAddendum() : '',
);
}
if (props.dangerouslySetInnerHTML != null) {
Expand Down Expand Up @@ -63,7 +65,7 @@ function assertValidProps(tag: string, props: ?Object) {
'The `style` prop expects a mapping from style properties to values, ' +
"not a string. For example, style={{marginRight: spacing + 'em'}} when " +
'using JSX.%s',
__DEV__ ? ReactDebugCurrentFrame.getStackAddendum() : '',
__DEV__ && ReactDebugCurrentFrame ? ReactDebugCurrentFrame.getStackAddendum() : '',
);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-renderer/src/__mocks__/deepDiffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

'use strict';
Expand Down
6 changes: 5 additions & 1 deletion packages/react/src/ReactLazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

import type {LazyComponent, Thenable} from 'shared/ReactLazyComponent';

import {REACT_LAZY_TYPE} from 'shared/ReactSymbols';

export function lazy<T, R>(ctor: () => Thenable<T, R>): LazyComponent<T> {
export function lazy<T>(
ctor: () => Thenable<{default: T}, mixed>,
): LazyComponent<T> {
return {
$$typeof: REACT_LAZY_TYPE,
_ctor: ctor,
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/forwardRef.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

import {REACT_FORWARD_REF_TYPE, REACT_MEMO_TYPE} from 'shared/ReactSymbols';
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/memo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

import {REACT_MEMO_TYPE} from 'shared/ReactSymbols';
Expand Down
2 changes: 1 addition & 1 deletion packages/scheduler/src/Scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function flushFirstCallback() {
// A callback may return a continuation. The continuation should be scheduled
// with the same priority and expiration as the just-finished callback.
if (typeof continuationCallback === 'function') {
var continuationNode: CallbackNode = {
var continuationNode = {
callback: continuationCallback,
priorityLevel,
expirationTime,
Expand Down
1 change: 1 addition & 0 deletions packages/scheduler/src/__tests__/SchedulerDOM-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
* @flow
*/

'use strict';
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/ReactLazyComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type Thenable<T, R> = {
export type LazyComponent<T> = {
$$typeof: Symbol | number,
_ctor: () => Thenable<{default: T}, mixed>,
_status: 0 | 1 | 2,
_status: -1 | 0 | 1 | 2, // TODO: what status is -1?
_result: any,
};

Expand Down
3 changes: 3 additions & 0 deletions packages/shared/forks/invokeGuardedCallbackImpl.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

import invariant from 'shared/invariant';

// Provided by www
// $FlowIssue
const ReactFbErrorUtils = require('ReactFbErrorUtils');
invariant(
typeof ReactFbErrorUtils.invokeGuardedCallback === 'function',
Expand Down