Flow: run codemod to remove existential type
The existential type `*` was deprecated and a codemod provided to replace it. Ran that and did some manual fixups: ```sh node_modules/.bin/flow codemod replace-existentials --write . ``` ghstack-source-id: 4c98b8db6a80159aa6ba3f2fc3659c11939da134 Pull Request resolved: https://github.com/facebook/react/pull/25416
Jan Kassens committed
Oct 4, 2022 at 13:25 UTC
1089faf0d88411921980b7d1dfe3f539b5fda1d3
16 files changed
+37
-47
packages/react-devtools-shared/src/devtools/ContextMenu/useContextMenu.js
+1
-1
@@ -22,7 +22,7 @@ export default function useContextMenu({
22
data: Object,
23
id: string,
24
onChange?: OnChangeFn,
25
- ref: {current: ElementRef<*> | null},
25
+ ref: {current: ElementRef<any> | null},
26
}) {
27
const {showMenu} = useContext<RegistryContextType>(RegistryContext);
28
packages/react-devtools-shared/src/devtools/views/Profiler/ChartNode.js
+4
-4
@@ -16,10 +16,10 @@ type Props = {
16
height: number,
17
isDimmed?: boolean,
18
label: string,
19
- onClick: (event: SyntheticMouseEvent<*>) => mixed,
20
- onDoubleClick?: (event: SyntheticMouseEvent<*>) => mixed,
21
- onMouseEnter: (event: SyntheticMouseEvent<*>) => mixed,
22
- onMouseLeave: (event: SyntheticMouseEvent<*>) => mixed,
19
+ onClick: (event: SyntheticMouseEvent<any>) => mixed,
20
+ onDoubleClick?: (event: SyntheticMouseEvent<any>) => mixed,
21
+ onMouseEnter: (event: SyntheticMouseEvent<any>) => mixed,
22
+ onMouseLeave: (event: SyntheticMouseEvent<any>) => mixed,
23
placeLabelAboveNode?: boolean,
24
textStyle?: Object,
25
width: number,
packages/react-devtools-shared/src/devtools/views/Profiler/CommitFlamegraphListItem.js
+1
-1
@@ -41,7 +41,7 @@ function CommitFlamegraphListItem({data, index, style}: Props): React.Node {
41
const {lineHeight} = useContext(SettingsContext);
42
43
const handleClick = useCallback(
44
- (event: SyntheticMouseEvent<*>, id: number, name: string) => {
44
+ (event: SyntheticMouseEvent<EventTarget>, id: number, name: string) => {
45
event.stopPropagation();
46
selectFiber(id, name);
47
},
packages/react-devtools-shared/src/devtools/views/Profiler/Tooltip.js
+3
-3
@@ -17,7 +17,7 @@ export default function Tooltip({
17
const tooltipRef = useRef(null);
18
19
// update the position of the tooltip based on current mouse position
20
- const updateTooltipPosition = (event: SyntheticMouseEvent<*>) => {
20
+ const updateTooltipPosition = (event: SyntheticMouseEvent<EventTarget>) => {
21
const element = tooltipRef.current;
22
if (element != null) {
23
// first find the mouse position
@@ -30,7 +30,7 @@ export default function Tooltip({
30
}
31
};
32
33
- const onMouseMove = (event: SyntheticMouseEvent<*>) => {
33
+ const onMouseMove = (event: SyntheticMouseEvent<EventTarget>) => {
34
updateTooltipPosition(event);
35
};
36
@@ -86,7 +86,7 @@ function getTooltipPosition(element, mousePosition) {
86
// method used to find the current mouse position inside the container
87
function getMousePosition(
88
relativeContainer,
89
- mouseEvent: SyntheticMouseEvent<*>,
89
+ mouseEvent: SyntheticMouseEvent<EventTarget>,
90
) {
91
if (relativeContainer !== null) {
92
// Position within the nearest position:relative container.
packages/react-devtools-shared/src/hooks/parseHookNames/loadSourceAndMetadata.js
+2
-2
@@ -134,7 +134,7 @@ function decodeBase64String(encoded: string): Object {
134
135
function extractAndLoadSourceMapJSON(
136
locationKeyToHookSourceAndMetadata: LocationKeyToHookSourceAndMetadata,
137
-): Promise<*> {
137
+): Promise<Array<$Call<<T>(p: Promise<T> | T) => T, Promise<void>>>> {
138
// Deduplicate fetches, since there can be multiple location keys per source map.
139
const dedupedFetchPromises = new Map();
140
@@ -459,7 +459,7 @@ function isUnnamedBuiltInHook(hook: HooksNode) {
459
function loadSourceFiles(
460
locationKeyToHookSourceAndMetadata: LocationKeyToHookSourceAndMetadata,
461
fetchFileWithCaching: FetchFileWithCaching | null,
462
-): Promise<*> {
462
+): Promise<Array<$Call<<T>(p: Promise<T> | T) => T, Promise<void>>>> {
463
// Deduplicate fetches, since there can be multiple location keys per file.
464
const dedupedFetchPromises = new Map();
465
packages/react-devtools-timeline/src/types.js
+1
-1
@@ -13,7 +13,7 @@ import type {ScrollState} from './view-base/utils/scrollState';
13
// eslint-disable-next-line no-unused-vars
14
type Return_<R, F: (...args: Array<any>) => R> = R;
15
/** Get return type of a function. */
16
-export type Return<T> = Return_<*, T>;
16
+export type Return<T> = Return_<mixed, T>;
17
18
// Project types
19
packages/react-dom-bindings/src/client/ReactDOMHostConfig.js
+3
-2
@@ -7,6 +7,7 @@
7
* @flow
8
*/
9
10
+import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
11
import type {DOMEventName} from '../events/DOMEventNames';
12
import type {Fiber, FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
13
import type {
@@ -209,7 +210,7 @@ export function getChildHostContext(
210
return getChildNamespace(parentNamespace, type);
211
}
212
212
-export function getPublicInstance(instance: Instance): * {
213
+export function getPublicInstance(instance: Instance): Instance {
214
return instance;
215
}
216
@@ -370,7 +371,7 @@ export function createTextInstance(
371
return textNode;
372
}
373
373
-export function getCurrentEventPriority(): * {
374
+export function getCurrentEventPriority(): EventPriority {
375
const currentEvent = window.event;
376
if (currentEvent === undefined) {
377
return DefaultEventPriority;
packages/react-dom-bindings/src/client/ReactDOMInput.js
+1
-1
@@ -415,7 +415,7 @@ function updateNamedCousins(rootNode, props) {
415
export function setDefaultValue(
416
node: InputWithWrapperState,
417
type: ?string,
418
- value: *,
418
+ value: ToStringValue,
419
) {
420
if (
421
// Focused number inputs synchronize on blur. See ChangeEventPlugin.js
packages/react-dom-bindings/src/events/ReactDOMEventListener.js
+2
-1
@@ -7,6 +7,7 @@
7
* @flow
8
*/
9
10
+import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
11
import type {AnyNativeEvent} from '../events/PluginModuleType';
12
import type {Fiber, FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
13
import type {Container, SuspenseInstance} from '../client/ReactDOMHostConfig';
@@ -407,7 +408,7 @@ export function findInstanceBlockingEvent(
408
return null;
409
}
410
410
-export function getEventPriority(domEventName: DOMEventName): * {
411
+export function getEventPriority(domEventName: DOMEventName): EventPriority {
412
switch (domEventName) {
413
// Used by SimpleEventPlugin:
414
case 'cancel':
packages/react-reconciler/src/ReactChildFiber.new.js
+3
-3
@@ -475,7 +475,7 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
475
function updateFragment(
476
returnFiber: Fiber,
477
current: Fiber | null,
478
- fragment: Iterable<*>,
478
+ fragment: Iterable<React$Node>,
479
lanes: Lanes,
480
key: null | string,
481
): Fiber {
@@ -750,7 +750,7 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
750
function reconcileChildrenArray(
751
returnFiber: Fiber,
752
currentFirstChild: Fiber | null,
753
- newChildren: Array<*>,
753
+ newChildren: Array<any>,
754
lanes: Lanes,
755
): Fiber | null {
756
// This algorithm can't optimize by searching from both ends since we
@@ -917,7 +917,7 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
917
function reconcileChildrenIterator(
918
returnFiber: Fiber,
919
currentFirstChild: Fiber | null,
920
- newChildrenIterable: Iterable<*>,
920
+ newChildrenIterable: Iterable<mixed>,
921
lanes: Lanes,
922
): Fiber | null {
923
// This is the same implementation as reconcileChildrenArray(),
packages/react-reconciler/src/ReactChildFiber.old.js
+3
-3
@@ -475,7 +475,7 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
475
function updateFragment(
476
returnFiber: Fiber,
477
current: Fiber | null,
478
- fragment: Iterable<*>,
478
+ fragment: Iterable<React$Node>,
479
lanes: Lanes,
480
key: null | string,
481
): Fiber {
@@ -750,7 +750,7 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
750
function reconcileChildrenArray(
751
returnFiber: Fiber,
752
currentFirstChild: Fiber | null,
753
- newChildren: Array<*>,
753
+ newChildren: Array<any>,
754
lanes: Lanes,
755
): Fiber | null {
756
// This algorithm can't optimize by searching from both ends since we
@@ -917,7 +917,7 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
917
function reconcileChildrenIterator(
918
returnFiber: Fiber,
919
currentFirstChild: Fiber | null,
920
- newChildrenIterable: Iterable<*>,
920
+ newChildrenIterable: Iterable<mixed>,
921
lanes: Lanes,
922
): Fiber | null {
923
// This is the same implementation as reconcileChildrenArray(),
packages/react-reconciler/src/ReactFiberClassUpdateQueue.new.js
+2
-2
@@ -207,8 +207,8 @@ export function cloneUpdateQueue<State>(
207
}
208
}
209
210
-export function createUpdate(eventTime: number, lane: Lane): Update<*> {
211
- const update: Update<*> = {
210
+export function createUpdate(eventTime: number, lane: Lane): Update<mixed> {
211
+ const update: Update<mixed> = {
212
eventTime,
213
lane,
214
packages/react-reconciler/src/ReactFiberClassUpdateQueue.old.js
+2
-2
@@ -207,8 +207,8 @@ export function cloneUpdateQueue<State>(
207
}
208
}
209
210
-export function createUpdate(eventTime: number, lane: Lane): Update<*> {
211
- const update: Update<*> = {
210
+export function createUpdate(eventTime: number, lane: Lane): Update<mixed> {
211
+ const update: Update<mixed> = {
212
eventTime,
213
lane,
214
packages/react-reconciler/src/ReactFiberCommitWork.new.js
+4
-10
@@ -883,7 +883,7 @@ function commitClassLayoutLifecycles(
883
function commitClassCallbacks(finishedWork: Fiber) {
884
// TODO: I think this is now always non-null by the time it reaches the
885
// commit phase. Consider removing the type check.
886
- const updateQueue: UpdateQueue<*> | null = (finishedWork.updateQueue: any);
886
+ const updateQueue: UpdateQueue<mixed> | null = (finishedWork.updateQueue: any);
887
if (updateQueue !== null) {
888
const instance = finishedWork.stateNode;
889
if (__DEV__) {
@@ -1050,9 +1050,7 @@ function commitLayoutEffectOnFiber(
1050
if (flags & Callback) {
1051
// TODO: I think this is now always non-null by the time it reaches the
1052
// commit phase. Consider removing the type check.
1053
- const updateQueue: UpdateQueue<
1054
- *,
1055
- > | null = (finishedWork.updateQueue: any);
1053
+ const updateQueue: UpdateQueue<mixed> | null = (finishedWork.updateQueue: any);
1054
if (updateQueue !== null) {
1055
let instance = null;
1056
if (finishedWork.child !== null) {
@@ -2521,9 +2519,7 @@ function commitMutationEffectsOnFiber(
2519
}
2520
2521
if (flags & Callback && offscreenSubtreeIsHidden) {
2524
- const updateQueue: UpdateQueue<
2525
- *,
2526
- > | null = (finishedWork.updateQueue: any);
2522
+ const updateQueue: UpdateQueue<mixed> | null = (finishedWork.updateQueue: any);
2523
if (updateQueue !== null) {
2524
deferHiddenCallbacks(updateQueue);
2525
}
@@ -3015,9 +3011,7 @@ export function reappearLayoutEffects(
3011
3012
// Commit any callbacks that would have fired while the component
3013
// was hidden.
3018
- const updateQueue: UpdateQueue<
3019
- *,
3020
- > | null = (finishedWork.updateQueue: any);
3014
+ const updateQueue: UpdateQueue<mixed> | null = (finishedWork.updateQueue: any);
3015
if (updateQueue !== null) {
3016
commitHiddenCallbacks(updateQueue, instance);
3017
}
packages/react-reconciler/src/ReactFiberCommitWork.old.js
+4
-10
@@ -883,7 +883,7 @@ function commitClassLayoutLifecycles(
883
function commitClassCallbacks(finishedWork: Fiber) {
884
// TODO: I think this is now always non-null by the time it reaches the
885
// commit phase. Consider removing the type check.
886
- const updateQueue: UpdateQueue<*> | null = (finishedWork.updateQueue: any);
886
+ const updateQueue: UpdateQueue<mixed> | null = (finishedWork.updateQueue: any);
887
if (updateQueue !== null) {
888
const instance = finishedWork.stateNode;
889
if (__DEV__) {
@@ -1050,9 +1050,7 @@ function commitLayoutEffectOnFiber(
1050
if (flags & Callback) {
1051
// TODO: I think this is now always non-null by the time it reaches the
1052
// commit phase. Consider removing the type check.
1053
- const updateQueue: UpdateQueue<
1054
- *,
1055
- > | null = (finishedWork.updateQueue: any);
1053
+ const updateQueue: UpdateQueue<mixed> | null = (finishedWork.updateQueue: any);
1054
if (updateQueue !== null) {
1055
let instance = null;
1056
if (finishedWork.child !== null) {
@@ -2521,9 +2519,7 @@ function commitMutationEffectsOnFiber(
2519
}
2520
2521
if (flags & Callback && offscreenSubtreeIsHidden) {
2524
- const updateQueue: UpdateQueue<
2525
- *,
2526
- > | null = (finishedWork.updateQueue: any);
2522
+ const updateQueue: UpdateQueue<mixed> | null = (finishedWork.updateQueue: any);
2523
if (updateQueue !== null) {
2524
deferHiddenCallbacks(updateQueue);
2525
}
@@ -3015,9 +3011,7 @@ export function reappearLayoutEffects(
3011
3012
// Commit any callbacks that would have fired while the component
3013
// was hidden.
3018
- const updateQueue: UpdateQueue<
3019
- *,
3020
- > | null = (finishedWork.updateQueue: any);
3014
+ const updateQueue: UpdateQueue<mixed> | null = (finishedWork.updateQueue: any);
3015
if (updateQueue !== null) {
3016
commitHiddenCallbacks(updateQueue, instance);
3017
}
packages/react-reconciler/src/ReactInternalTypes.js
+1
-1
@@ -238,7 +238,7 @@ type BaseFiberRootProperties = {
238
239
// Node returned by Scheduler.scheduleCallback. Represents the next rendering
240
// task that the root will work on.
241
- callbackNode: *,
241
+ callbackNode: any,
242
callbackPriority: Lane,
243
eventTimes: LaneMap<number>,
244
expirationTimes: LaneMap<number>,