Flow: ReactFiberHotReloading recursive type (#25225)

This commit is contained in:
Jan Kassens
2022-09-12 10:25:01 -04:00
committed by GitHub
parent c156ecd483
commit c739cef2fc
3 changed files with 45 additions and 55 deletions
+25 -9
View File
@@ -7,16 +7,11 @@
* @flow
*/
import {enableNewReconciler} from 'shared/ReactFeatureFlags';
import type {Instance} from './ReactFiberHostConfig';
import type {FiberRoot} from './ReactInternalTypes';
import type {ReactNodeList} from 'shared/ReactTypes';
export type {
Family,
RefreshUpdate,
SetRefreshHandler,
ScheduleRefresh,
ScheduleRoot,
FindHostInstancesForRefresh,
} from './ReactFiberHotReloading';
import {enableNewReconciler} from 'shared/ReactFeatureFlags';
import {
setRefreshHandler as setRefreshHandler_old,
@@ -42,6 +37,27 @@ import {
findHostInstancesForRefresh as findHostInstancesForRefresh_new,
} from './ReactFiberHotReloading.new';
export type Family = {
current: any,
};
export type RefreshUpdate = {
staleFamilies: Set<Family>,
updatedFamilies: Set<Family>,
};
// Resolves type to a family.
export type RefreshHandler = any => Family | void;
// Used by React Refresh runtime through DevTools Global Hook.
export type SetRefreshHandler = (handler: RefreshHandler | null) => void;
export type ScheduleRefresh = (root: FiberRoot, update: RefreshUpdate) => void;
export type ScheduleRoot = (root: FiberRoot, element: ReactNodeList) => void;
export type FindHostInstancesForRefresh = (
root: FiberRoot,
families: Array<Family>,
) => Set<Instance>;
export const setRefreshHandler = enableNewReconciler
? setRefreshHandler_new
: setRefreshHandler_old;
@@ -10,11 +10,19 @@
/* eslint-disable react-internal/prod-error-codes */
import type {ReactElement} from 'shared/ReactElementType';
import type {Fiber} from './ReactInternalTypes';
import type {FiberRoot} from './ReactInternalTypes';
import type {Fiber, FiberRoot} from './ReactInternalTypes';
import type {Instance} from './ReactFiberHostConfig';
import type {ReactNodeList} from 'shared/ReactTypes';
import type {
Family,
FindHostInstancesForRefresh,
RefreshHandler,
RefreshUpdate,
ScheduleRefresh,
ScheduleRoot,
} from './ReactFiberHotReloading';
import {
flushSync,
scheduleUpdateOnFiber,
@@ -40,27 +48,6 @@ import {
REACT_LAZY_TYPE,
} from 'shared/ReactSymbols';
export type Family = {
current: any,
};
export type RefreshUpdate = {
staleFamilies: Set<Family>,
updatedFamilies: Set<Family>,
};
// Resolves type to a family.
type RefreshHandler = any => Family | void;
// Used by React Refresh runtime through DevTools Global Hook.
export type SetRefreshHandler = (handler: RefreshHandler | null) => void;
export type ScheduleRefresh = (root: FiberRoot, update: RefreshUpdate) => void;
export type ScheduleRoot = (root: FiberRoot, element: ReactNodeList) => void;
export type FindHostInstancesForRefresh = (
root: FiberRoot,
families: Array<Family>,
) => Set<Instance>;
let resolveFamily: RefreshHandler | null = null;
// $FlowFixMe Flow gets confused by a WeakSet feature check below.
let failedBoundaries: WeakSet<Fiber> | null = null;
@@ -10,11 +10,19 @@
/* eslint-disable react-internal/prod-error-codes */
import type {ReactElement} from 'shared/ReactElementType';
import type {Fiber} from './ReactInternalTypes';
import type {FiberRoot} from './ReactInternalTypes';
import type {Fiber, FiberRoot} from './ReactInternalTypes';
import type {Instance} from './ReactFiberHostConfig';
import type {ReactNodeList} from 'shared/ReactTypes';
import type {
Family,
FindHostInstancesForRefresh,
RefreshHandler,
RefreshUpdate,
ScheduleRefresh,
ScheduleRoot,
} from './ReactFiberHotReloading';
import {
flushSync,
scheduleUpdateOnFiber,
@@ -40,27 +48,6 @@ import {
REACT_LAZY_TYPE,
} from 'shared/ReactSymbols';
export type Family = {
current: any,
};
export type RefreshUpdate = {
staleFamilies: Set<Family>,
updatedFamilies: Set<Family>,
};
// Resolves type to a family.
type RefreshHandler = any => Family | void;
// Used by React Refresh runtime through DevTools Global Hook.
export type SetRefreshHandler = (handler: RefreshHandler | null) => void;
export type ScheduleRefresh = (root: FiberRoot, update: RefreshUpdate) => void;
export type ScheduleRoot = (root: FiberRoot, element: ReactNodeList) => void;
export type FindHostInstancesForRefresh = (
root: FiberRoot,
families: Array<Family>,
) => Set<Instance>;
let resolveFamily: RefreshHandler | null = null;
// $FlowFixMe Flow gets confused by a WeakSet feature check below.
let failedBoundaries: WeakSet<Fiber> | null = null;