Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flow: fix ReactFiberHotReloading recursive type #25225

Merged
merged 1 commit into from
Sep 12, 2022
Merged
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
34 changes: 25 additions & 9 deletions packages/react-reconciler/src/ReactFiberHotReloading.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down
33 changes: 10 additions & 23 deletions packages/react-reconciler/src/ReactFiberHotReloading.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down
33 changes: 10 additions & 23 deletions packages/react-reconciler/src/ReactFiberHotReloading.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down