Skip to content

Commit 267d1f4

Browse files
committed
[WIP] Flow
1 parent 22e6ea3 commit 267d1f4

30 files changed

+503
-382
lines changed

.flowconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
<PROJECT_ROOT>/.*/__mocks__/.*
1616
<PROJECT_ROOT>/.*/__tests__/.*
1717

18+
# TODO
19+
<PROJECT_ROOT>/packages/react-noop-renderer/.*
20+
1821
[include]
1922

2023
[libs]
@@ -29,6 +32,11 @@ esproposal.class_static_fields=enable
2932
esproposal.class_instance_fields=enable
3033
unsafe.enable_getters_and_setters=true
3134

35+
# This would enable ReactDOM-specific check.
36+
# TODO: scripts that run this.
37+
# module.name_mapper='react-reconciler/inline.dom$' -> 'react-reconciler/inline.typed'
38+
# module.name_mapper='ReactFiberHostConfig' -> '<PROJECT_ROOT>/packages/react-dom/src/client/ReactDOMHostConfig'
39+
3240
munge_underscores=false
3341

3442
suppress_type=$FlowIssue

packages/react-art/src/ReactART.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import React from 'react';
9-
import * as ARTRenderer from 'react-reconciler/inline';
9+
import * as ARTRenderer from 'react-reconciler/inline.art';
1010
import Transform from 'art/core/transform';
1111
import Mode from 'art/modes/current';
1212
import FastNoSideEffects from 'art/modes/fast-noSideEffects';

packages/react-dom/src/client/ReactDOM.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import type {Container} from './ReactDOMHostConfig';
1919
import '../shared/checkReact';
2020
import './ReactDOMClientInjection';
2121

22-
import * as DOMRenderer from 'react-reconciler/inline';
22+
import * as DOMRenderer from 'react-reconciler/inline.dom';
2323
import * as ReactPortal from 'shared/ReactPortal';
2424
import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
2525
import * as ReactGenericBatching from 'events/ReactGenericBatching';

packages/react-dom/src/client/ReactDOMHostConfig.js

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ import {
2424
DOCUMENT_FRAGMENT_NODE,
2525
} from '../shared/HTMLNodeType';
2626

27+
28+
export type T = string;
29+
export type P = any;
30+
export type I = Element;
31+
export type TI = Text;
32+
export type HI = any;
33+
export type PI = Element | Text;
34+
export type C = Element | Document;
35+
export type CC = void;
36+
export type CX = string | { namespace: string, ancestorInfo: mixed };
37+
export type PL = Array<mixed>;
38+
39+
2740
export type Container = Element | Document;
2841
type Props = {
2942
autoFocus?: boolean,
@@ -111,6 +124,7 @@ export function getRootHostContext(rootContainerInstance: Container): HostContex
111124
export function getChildHostContext(
112125
parentHostContext: HostContext,
113126
type: string,
127+
instance: *
114128
): HostContext {
115129
if (__DEV__) {
116130
const parentHostContextDev = ((parentHostContext: any): HostContextDev);
@@ -130,13 +144,13 @@ export function getPublicInstance(instance: Instance | TextInstance): * {
130144
return instance;
131145
}
132146

133-
export function prepareForCommit(): void {
147+
export function prepareForCommit(containerInfo: *): void {
134148
eventsEnabled = ReactBrowserEventEmitter.isEnabled();
135149
selectionInformation = ReactInputSelection.getSelectionInformation();
136150
ReactBrowserEventEmitter.setEnabled(false);
137151
}
138152

139-
export function resetAfterCommit(): void {
153+
export function resetAfterCommit(containerInfo: *): void {
140154
ReactInputSelection.restoreSelection(selectionInformation);
141155
selectionInformation = null;
142156
ReactBrowserEventEmitter.setEnabled(eventsEnabled);
@@ -194,6 +208,7 @@ export function finalizeInitialChildren(
194208
type: string,
195209
props: Props,
196210
rootContainerInstance: Container,
211+
hostContext: *,
197212
): boolean {
198213
setInitialProperties(domElement, type, props, rootContainerInstance);
199214
return shouldAutoFocusHostComponent(type, props);
@@ -566,23 +581,45 @@ export function prepareUpdate(
566581
export const cancelDeferredCallback = ReactScheduler.cancelScheduledWork;
567582

568583

569-
export function cloneInstance() {
584+
// TODO
585+
586+
export function cloneInstance(
587+
instance: Instance,
588+
updatePayload: null | Array<mixed>,
589+
type: string,
590+
oldProps: Props,
591+
newProps: Props,
592+
internalInstanceHandle: Object,
593+
keepChildren: boolean,
594+
recyclableInstance: Instance,
595+
): Instance {
596+
return instance;
570597
// not supported
571598
}
572599

573-
export function createContainerChildSet() {
600+
export function createContainerChildSet(
601+
container: Container
602+
): void {
574603
// not supported
575604
}
576605

577-
export function appendChildToContainerChildSet() {
606+
export function appendChildToContainerChildSet(
607+
childSet: void, child: Instance | TextInstance
608+
): void {
578609
// not supported
579610
}
580611

581-
export function finalizeContainerChildren() {
612+
export function finalizeContainerChildren(
613+
container: Container,
614+
newChildren: void
615+
) {
582616
// not supported
583617
}
584618

585-
export function replaceContainerChildren() {
619+
export function replaceContainerChildren(
620+
container: Container,
621+
newChildren: void
622+
) {
586623
// not supported
587624
}
588625

packages/react-native-renderer/src/ReactFabric.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {ReactNodeList} from 'shared/ReactTypes';
1212

1313
import './ReactFabricInjection';
1414

15-
import * as ReactFabricRenderer from 'react-reconciler/inline';
15+
import * as ReactFabricRenderer from 'react-reconciler/inline.fabric';
1616

1717
import * as ReactPortal from 'shared/ReactPortal';
1818
import * as ReactGenericBatching from 'events/ReactGenericBatching';

packages/react-native-renderer/src/ReactNativeRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {ReactNodeList} from 'shared/ReactTypes';
1212

1313
import './ReactNativeInjection';
1414

15-
import * as ReactNativeFiberRenderer from 'react-reconciler/inline';
15+
import * as ReactNativeFiberRenderer from 'react-reconciler/inline.native';
1616
import * as ReactPortal from 'shared/ReactPortal';
1717
import * as ReactGenericBatching from 'events/ReactGenericBatching';
1818
import ReactVersion from 'shared/ReactVersion';

packages/react-noop-renderer/src/createReactNoop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @flow
7+
* @ TODO !!!!!!!!!!!!!!!!!!
88
*/
99

1010
/**

packages/react-reconciler/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @flow
7+
* @ TODO !!!!!!!!!!!!!!!!!!
88
*/
99

1010
'use strict';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// TODO
2+
export * from './src/ReactFiberReconciler';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// TODO
2+
export * from './src/ReactFiberReconciler';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// TODO
2+
export * from './src/ReactFiberReconciler';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// TODO
2+
export * from './src/ReactFiberReconciler';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// TODO
2+
export * from './src/ReactFiberReconciler';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// @flow
2+
3+
// TODO
4+
export * from './src/ReactFiberReconciler';

packages/react-reconciler/src/ReactFiberBeginWork.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,10 @@
77
* @flow
88
*/
99

10-
import type {HostConfig} from 'react-reconciler';
1110
import type {ReactProviderType, ReactContext} from 'shared/ReactTypes';
1211
import type {Fiber} from 'react-reconciler/src/ReactFiber';
13-
import type {HostContext} from './ReactFiberHostContext';
14-
import type {LegacyContext} from './ReactFiberContext';
15-
import type {NewContext} from './ReactFiberNewContext';
16-
import type {HydrationContext} from './ReactFiberHydrationContext';
1712
import type {FiberRoot} from './ReactFiberRoot';
1813
import type {ExpirationTime} from './ReactFiberExpirationTime';
19-
import type {ProfilerTimer} from './ReactProfilerTimer';
2014
import checkPropTypes from 'prop-types/checkPropTypes';
2115

2216
import {

packages/react-reconciler/src/ReactFiberClassComponent.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import type {Fiber} from './ReactFiber';
1111
import type {ExpirationTime} from './ReactFiberExpirationTime';
12-
import type {LegacyContext} from './ReactFiberContext';
1312

1413
import {Update, Snapshot} from 'shared/ReactTypeOfSideEffect';
1514
import {

packages/react-reconciler/src/ReactFiberCommitWork.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow
88
*/
99

10-
import type {HostConfig} from 'react-reconciler';
10+
import type {I, TI, C, CC, PL} from './ReactFiberHostConfig';
1111
import type {Fiber} from './ReactFiber';
1212
import type {FiberRoot} from './ReactFiberRoot';
1313
import type {ExpirationTime} from './ReactFiberExpirationTime';

packages/react-reconciler/src/ReactFiberCompleteWork.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,10 @@
77
* @flow
88
*/
99

10-
import type {HostConfig} from 'react-reconciler';
1110
import type {Fiber} from './ReactFiber';
1211
import type {ExpirationTime} from './ReactFiberExpirationTime';
13-
import type {HostContext} from './ReactFiberHostContext';
14-
import type {LegacyContext} from './ReactFiberContext';
15-
import type {NewContext} from './ReactFiberNewContext';
16-
import type {HydrationContext} from './ReactFiberHydrationContext';
1712
import type {FiberRoot} from './ReactFiberRoot';
18-
import type {ProfilerTimer} from './ReactProfilerTimer';
13+
import type {T, P, I, TI, HI, PI, C, CC, CX, PL} from './ReactFiberHostConfig';
1914

2015
import {
2116
enableMutatingReconciler,

packages/react-reconciler/src/ReactFiberContext.js

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
import type {Fiber} from './ReactFiber';
11-
import type {StackCursor, Stack} from './ReactFiberStack';
11+
import type {StackCursor} from './ReactFiberStack';
1212

1313
import {isFiberMounted} from 'react-reconciler/reflection';
1414
import {ClassComponent, HostRoot} from 'shared/ReactTypeOfWork';
@@ -28,30 +28,6 @@ if (__DEV__) {
2828
warnedAboutMissingGetChildContext = {};
2929
}
3030

31-
export type LegacyContext = {
32-
getUnmaskedContext(workInProgress: Fiber): Object,
33-
cacheContext(
34-
workInProgress: Fiber,
35-
unmaskedContext: Object,
36-
maskedContext: Object,
37-
): void,
38-
getMaskedContext(workInProgress: Fiber, unmaskedContext: Object): Object,
39-
hasContextChanged(): boolean,
40-
isContextConsumer(fiber: Fiber): boolean,
41-
isContextProvider(fiber: Fiber): boolean,
42-
popContextProvider(fiber: Fiber): void,
43-
popTopLevelContextObject(fiber: Fiber): void,
44-
pushTopLevelContextObject(
45-
fiber: Fiber,
46-
context: Object,
47-
didChange: boolean,
48-
): void,
49-
processChildContext(fiber: Fiber, parentContext: Object): Object,
50-
pushContextProvider(workInProgress: Fiber): boolean,
51-
invalidateContextProvider(workInProgress: Fiber, didChange: boolean): void,
52-
findCurrentUnmaskedContext(fiber: Fiber): Object,
53-
};
54-
5531
// A cursor to the current merged context object on the stack.
5632
let contextStackCursor: StackCursor<Object> = createCursor(emptyObject);
5733
// A cursor to a boolean indicating whether the context has changed.
@@ -77,13 +53,13 @@ export type LegacyContext = {
7753
workInProgress: Fiber,
7854
unmaskedContext: Object,
7955
maskedContext: Object,
80-
) {
56+
): void {
8157
const instance = workInProgress.stateNode;
8258
instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
8359
instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
8460
}
8561

86-
function getMaskedContext(workInProgress: Fiber, unmaskedContext: Object) {
62+
function getMaskedContext(workInProgress: Fiber, unmaskedContext: Object): Object {
8763
const type = workInProgress.type;
8864
const contextTypes = type.contextTypes;
8965
if (!contextTypes) {
@@ -147,7 +123,7 @@ export type LegacyContext = {
147123
pop(contextStackCursor, fiber);
148124
}
149125

150-
function popTopLevelContextObject(fiber: Fiber) {
126+
function popTopLevelContextObject(fiber: Fiber): void {
151127
pop(didPerformWorkStackCursor, fiber);
152128
pop(contextStackCursor, fiber);
153129
}

0 commit comments

Comments
 (0)