Skip to content

Commit c739cef

Browse files
authored
Flow: ReactFiberHotReloading recursive type (#25225)
1 parent c156ecd commit c739cef

File tree

3 files changed

+45
-55
lines changed

3 files changed

+45
-55
lines changed

packages/react-reconciler/src/ReactFiberHotReloading.js

+25-9
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,11 @@
77
* @flow
88
*/
99

10-
import {enableNewReconciler} from 'shared/ReactFeatureFlags';
10+
import type {Instance} from './ReactFiberHostConfig';
11+
import type {FiberRoot} from './ReactInternalTypes';
12+
import type {ReactNodeList} from 'shared/ReactTypes';
1113

12-
export type {
13-
Family,
14-
RefreshUpdate,
15-
SetRefreshHandler,
16-
ScheduleRefresh,
17-
ScheduleRoot,
18-
FindHostInstancesForRefresh,
19-
} from './ReactFiberHotReloading';
14+
import {enableNewReconciler} from 'shared/ReactFeatureFlags';
2015

2116
import {
2217
setRefreshHandler as setRefreshHandler_old,
@@ -42,6 +37,27 @@ import {
4237
findHostInstancesForRefresh as findHostInstancesForRefresh_new,
4338
} from './ReactFiberHotReloading.new';
4439

40+
export type Family = {
41+
current: any,
42+
};
43+
44+
export type RefreshUpdate = {
45+
staleFamilies: Set<Family>,
46+
updatedFamilies: Set<Family>,
47+
};
48+
49+
// Resolves type to a family.
50+
export type RefreshHandler = any => Family | void;
51+
52+
// Used by React Refresh runtime through DevTools Global Hook.
53+
export type SetRefreshHandler = (handler: RefreshHandler | null) => void;
54+
export type ScheduleRefresh = (root: FiberRoot, update: RefreshUpdate) => void;
55+
export type ScheduleRoot = (root: FiberRoot, element: ReactNodeList) => void;
56+
export type FindHostInstancesForRefresh = (
57+
root: FiberRoot,
58+
families: Array<Family>,
59+
) => Set<Instance>;
60+
4561
export const setRefreshHandler = enableNewReconciler
4662
? setRefreshHandler_new
4763
: setRefreshHandler_old;

packages/react-reconciler/src/ReactFiberHotReloading.new.js

+10-23
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@
1010
/* eslint-disable react-internal/prod-error-codes */
1111

1212
import type {ReactElement} from 'shared/ReactElementType';
13-
import type {Fiber} from './ReactInternalTypes';
14-
import type {FiberRoot} from './ReactInternalTypes';
13+
import type {Fiber, FiberRoot} from './ReactInternalTypes';
1514
import type {Instance} from './ReactFiberHostConfig';
1615
import type {ReactNodeList} from 'shared/ReactTypes';
1716

17+
import type {
18+
Family,
19+
FindHostInstancesForRefresh,
20+
RefreshHandler,
21+
RefreshUpdate,
22+
ScheduleRefresh,
23+
ScheduleRoot,
24+
} from './ReactFiberHotReloading';
25+
1826
import {
1927
flushSync,
2028
scheduleUpdateOnFiber,
@@ -40,27 +48,6 @@ import {
4048
REACT_LAZY_TYPE,
4149
} from 'shared/ReactSymbols';
4250

43-
export type Family = {
44-
current: any,
45-
};
46-
47-
export type RefreshUpdate = {
48-
staleFamilies: Set<Family>,
49-
updatedFamilies: Set<Family>,
50-
};
51-
52-
// Resolves type to a family.
53-
type RefreshHandler = any => Family | void;
54-
55-
// Used by React Refresh runtime through DevTools Global Hook.
56-
export type SetRefreshHandler = (handler: RefreshHandler | null) => void;
57-
export type ScheduleRefresh = (root: FiberRoot, update: RefreshUpdate) => void;
58-
export type ScheduleRoot = (root: FiberRoot, element: ReactNodeList) => void;
59-
export type FindHostInstancesForRefresh = (
60-
root: FiberRoot,
61-
families: Array<Family>,
62-
) => Set<Instance>;
63-
6451
let resolveFamily: RefreshHandler | null = null;
6552
// $FlowFixMe Flow gets confused by a WeakSet feature check below.
6653
let failedBoundaries: WeakSet<Fiber> | null = null;

packages/react-reconciler/src/ReactFiberHotReloading.old.js

+10-23
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@
1010
/* eslint-disable react-internal/prod-error-codes */
1111

1212
import type {ReactElement} from 'shared/ReactElementType';
13-
import type {Fiber} from './ReactInternalTypes';
14-
import type {FiberRoot} from './ReactInternalTypes';
13+
import type {Fiber, FiberRoot} from './ReactInternalTypes';
1514
import type {Instance} from './ReactFiberHostConfig';
1615
import type {ReactNodeList} from 'shared/ReactTypes';
1716

17+
import type {
18+
Family,
19+
FindHostInstancesForRefresh,
20+
RefreshHandler,
21+
RefreshUpdate,
22+
ScheduleRefresh,
23+
ScheduleRoot,
24+
} from './ReactFiberHotReloading';
25+
1826
import {
1927
flushSync,
2028
scheduleUpdateOnFiber,
@@ -40,27 +48,6 @@ import {
4048
REACT_LAZY_TYPE,
4149
} from 'shared/ReactSymbols';
4250

43-
export type Family = {
44-
current: any,
45-
};
46-
47-
export type RefreshUpdate = {
48-
staleFamilies: Set<Family>,
49-
updatedFamilies: Set<Family>,
50-
};
51-
52-
// Resolves type to a family.
53-
type RefreshHandler = any => Family | void;
54-
55-
// Used by React Refresh runtime through DevTools Global Hook.
56-
export type SetRefreshHandler = (handler: RefreshHandler | null) => void;
57-
export type ScheduleRefresh = (root: FiberRoot, update: RefreshUpdate) => void;
58-
export type ScheduleRoot = (root: FiberRoot, element: ReactNodeList) => void;
59-
export type FindHostInstancesForRefresh = (
60-
root: FiberRoot,
61-
families: Array<Family>,
62-
) => Set<Instance>;
63-
6451
let resolveFamily: RefreshHandler | null = null;
6552
// $FlowFixMe Flow gets confused by a WeakSet feature check below.
6653
let failedBoundaries: WeakSet<Fiber> | null = null;

0 commit comments

Comments
 (0)