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: run codemod to remove existential type #25416

Merged
merged 2 commits into from
Oct 4, 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function useContextMenu({
data: Object,
id: string,
onChange?: OnChangeFn,
ref: {current: ElementRef<*> | null},
ref: {current: ElementRef<any> | null},
}) {
const {showMenu} = useContext<RegistryContextType>(RegistryContext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ type Props = {
height: number,
isDimmed?: boolean,
label: string,
onClick: (event: SyntheticMouseEvent<*>) => mixed,
onDoubleClick?: (event: SyntheticMouseEvent<*>) => mixed,
onMouseEnter: (event: SyntheticMouseEvent<*>) => mixed,
onMouseLeave: (event: SyntheticMouseEvent<*>) => mixed,
onClick: (event: SyntheticMouseEvent<any>) => mixed,
onDoubleClick?: (event: SyntheticMouseEvent<any>) => mixed,
onMouseEnter: (event: SyntheticMouseEvent<any>) => mixed,
onMouseLeave: (event: SyntheticMouseEvent<any>) => mixed,
placeLabelAboveNode?: boolean,
textStyle?: Object,
width: number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function CommitFlamegraphListItem({data, index, style}: Props): React.Node {
const {lineHeight} = useContext(SettingsContext);

const handleClick = useCallback(
(event: SyntheticMouseEvent<*>, id: number, name: string) => {
(event: SyntheticMouseEvent<EventTarget>, id: number, name: string) => {
event.stopPropagation();
selectFiber(id, name);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function Tooltip({
const tooltipRef = useRef(null);

// update the position of the tooltip based on current mouse position
const updateTooltipPosition = (event: SyntheticMouseEvent<*>) => {
const updateTooltipPosition = (event: SyntheticMouseEvent<EventTarget>) => {
const element = tooltipRef.current;
if (element != null) {
// first find the mouse position
Expand All @@ -30,7 +30,7 @@ export default function Tooltip({
}
};

const onMouseMove = (event: SyntheticMouseEvent<*>) => {
const onMouseMove = (event: SyntheticMouseEvent<EventTarget>) => {
updateTooltipPosition(event);
};

Expand Down Expand Up @@ -86,7 +86,7 @@ function getTooltipPosition(element, mousePosition) {
// method used to find the current mouse position inside the container
function getMousePosition(
relativeContainer,
mouseEvent: SyntheticMouseEvent<*>,
mouseEvent: SyntheticMouseEvent<EventTarget>,
) {
if (relativeContainer !== null) {
// Position within the nearest position:relative container.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function decodeBase64String(encoded: string): Object {

function extractAndLoadSourceMapJSON(
locationKeyToHookSourceAndMetadata: LocationKeyToHookSourceAndMetadata,
): Promise<*> {
): Promise<Array<$Call<<T>(p: Promise<T> | T) => T, Promise<void>>>> {
// Deduplicate fetches, since there can be multiple location keys per source map.
const dedupedFetchPromises = new Map();

Expand Down Expand Up @@ -459,7 +459,7 @@ function isUnnamedBuiltInHook(hook: HooksNode) {
function loadSourceFiles(
locationKeyToHookSourceAndMetadata: LocationKeyToHookSourceAndMetadata,
fetchFileWithCaching: FetchFileWithCaching | null,
): Promise<*> {
): Promise<Array<$Call<<T>(p: Promise<T> | T) => T, Promise<void>>>> {
// Deduplicate fetches, since there can be multiple location keys per file.
const dedupedFetchPromises = new Map();

Expand Down
2 changes: 1 addition & 1 deletion packages/react-devtools-timeline/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {ScrollState} from './view-base/utils/scrollState';
// eslint-disable-next-line no-unused-vars
type Return_<R, F: (...args: Array<any>) => R> = R;
/** Get return type of a function. */
export type Return<T> = Return_<*, T>;
export type Return<T> = Return_<mixed, T>;

// Project types

Expand Down
5 changes: 3 additions & 2 deletions packages/react-dom-bindings/src/client/ReactDOMHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @flow
*/

import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
import type {DOMEventName} from '../events/DOMEventNames';
import type {Fiber, FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
import type {
Expand Down Expand Up @@ -209,7 +210,7 @@ export function getChildHostContext(
return getChildNamespace(parentNamespace, type);
}

export function getPublicInstance(instance: Instance): * {
export function getPublicInstance(instance: Instance): Instance {
return instance;
}

Expand Down Expand Up @@ -370,7 +371,7 @@ export function createTextInstance(
return textNode;
}

export function getCurrentEventPriority(): * {
export function getCurrentEventPriority(): EventPriority {
const currentEvent = window.event;
if (currentEvent === undefined) {
return DefaultEventPriority;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom-bindings/src/client/ReactDOMInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ function updateNamedCousins(rootNode, props) {
export function setDefaultValue(
node: InputWithWrapperState,
type: ?string,
value: *,
value: ToStringValue,
) {
if (
// Focused number inputs synchronize on blur. See ChangeEventPlugin.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @flow
*/

import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
import type {AnyNativeEvent} from '../events/PluginModuleType';
import type {Fiber, FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
import type {Container, SuspenseInstance} from '../client/ReactDOMHostConfig';
Expand Down Expand Up @@ -407,7 +408,7 @@ export function findInstanceBlockingEvent(
return null;
}

export function getEventPriority(domEventName: DOMEventName): * {
export function getEventPriority(domEventName: DOMEventName): EventPriority {
switch (domEventName) {
// Used by SimpleEventPlugin:
case 'cancel':
Expand Down
6 changes: 3 additions & 3 deletions packages/react-reconciler/src/ReactChildFiber.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
function updateFragment(
returnFiber: Fiber,
current: Fiber | null,
fragment: Iterable<*>,
fragment: Iterable<React$Node>,
lanes: Lanes,
key: null | string,
): Fiber {
Expand Down Expand Up @@ -750,7 +750,7 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
function reconcileChildrenArray(
returnFiber: Fiber,
currentFirstChild: Fiber | null,
newChildren: Array<*>,
newChildren: Array<any>,
lanes: Lanes,
): Fiber | null {
// This algorithm can't optimize by searching from both ends since we
Expand Down Expand Up @@ -917,7 +917,7 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
function reconcileChildrenIterator(
returnFiber: Fiber,
currentFirstChild: Fiber | null,
newChildrenIterable: Iterable<*>,
newChildrenIterable: Iterable<mixed>,
lanes: Lanes,
): Fiber | null {
// This is the same implementation as reconcileChildrenArray(),
Expand Down
6 changes: 3 additions & 3 deletions packages/react-reconciler/src/ReactChildFiber.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
function updateFragment(
returnFiber: Fiber,
current: Fiber | null,
fragment: Iterable<*>,
fragment: Iterable<React$Node>,
lanes: Lanes,
key: null | string,
): Fiber {
Expand Down Expand Up @@ -750,7 +750,7 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
function reconcileChildrenArray(
returnFiber: Fiber,
currentFirstChild: Fiber | null,
newChildren: Array<*>,
newChildren: Array<any>,
lanes: Lanes,
): Fiber | null {
// This algorithm can't optimize by searching from both ends since we
Expand Down Expand Up @@ -917,7 +917,7 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
function reconcileChildrenIterator(
returnFiber: Fiber,
currentFirstChild: Fiber | null,
newChildrenIterable: Iterable<*>,
newChildrenIterable: Iterable<mixed>,
lanes: Lanes,
): Fiber | null {
// This is the same implementation as reconcileChildrenArray(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ export function cloneUpdateQueue<State>(
}
}

export function createUpdate(eventTime: number, lane: Lane): Update<*> {
const update: Update<*> = {
export function createUpdate(eventTime: number, lane: Lane): Update<mixed> {
const update: Update<mixed> = {
eventTime,
lane,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ export function cloneUpdateQueue<State>(
}
}

export function createUpdate(eventTime: number, lane: Lane): Update<*> {
const update: Update<*> = {
export function createUpdate(eventTime: number, lane: Lane): Update<mixed> {
const update: Update<mixed> = {
eventTime,
lane,

Expand Down
14 changes: 4 additions & 10 deletions packages/react-reconciler/src/ReactFiberCommitWork.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ function commitClassLayoutLifecycles(
function commitClassCallbacks(finishedWork: Fiber) {
// TODO: I think this is now always non-null by the time it reaches the
// commit phase. Consider removing the type check.
const updateQueue: UpdateQueue<*> | null = (finishedWork.updateQueue: any);
const updateQueue: UpdateQueue<mixed> | null = (finishedWork.updateQueue: any);
if (updateQueue !== null) {
const instance = finishedWork.stateNode;
if (__DEV__) {
Expand Down Expand Up @@ -1050,9 +1050,7 @@ function commitLayoutEffectOnFiber(
if (flags & Callback) {
// TODO: I think this is now always non-null by the time it reaches the
// commit phase. Consider removing the type check.
const updateQueue: UpdateQueue<
*,
> | null = (finishedWork.updateQueue: any);
const updateQueue: UpdateQueue<mixed> | null = (finishedWork.updateQueue: any);
if (updateQueue !== null) {
let instance = null;
if (finishedWork.child !== null) {
Expand Down Expand Up @@ -2521,9 +2519,7 @@ function commitMutationEffectsOnFiber(
}

if (flags & Callback && offscreenSubtreeIsHidden) {
const updateQueue: UpdateQueue<
*,
> | null = (finishedWork.updateQueue: any);
const updateQueue: UpdateQueue<mixed> | null = (finishedWork.updateQueue: any);
if (updateQueue !== null) {
deferHiddenCallbacks(updateQueue);
}
Expand Down Expand Up @@ -3015,9 +3011,7 @@ export function reappearLayoutEffects(

// Commit any callbacks that would have fired while the component
// was hidden.
const updateQueue: UpdateQueue<
*,
> | null = (finishedWork.updateQueue: any);
const updateQueue: UpdateQueue<mixed> | null = (finishedWork.updateQueue: any);
if (updateQueue !== null) {
commitHiddenCallbacks(updateQueue, instance);
}
Expand Down
14 changes: 4 additions & 10 deletions packages/react-reconciler/src/ReactFiberCommitWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ function commitClassLayoutLifecycles(
function commitClassCallbacks(finishedWork: Fiber) {
// TODO: I think this is now always non-null by the time it reaches the
// commit phase. Consider removing the type check.
const updateQueue: UpdateQueue<*> | null = (finishedWork.updateQueue: any);
const updateQueue: UpdateQueue<mixed> | null = (finishedWork.updateQueue: any);
if (updateQueue !== null) {
const instance = finishedWork.stateNode;
if (__DEV__) {
Expand Down Expand Up @@ -1050,9 +1050,7 @@ function commitLayoutEffectOnFiber(
if (flags & Callback) {
// TODO: I think this is now always non-null by the time it reaches the
// commit phase. Consider removing the type check.
const updateQueue: UpdateQueue<
*,
> | null = (finishedWork.updateQueue: any);
const updateQueue: UpdateQueue<mixed> | null = (finishedWork.updateQueue: any);
if (updateQueue !== null) {
let instance = null;
if (finishedWork.child !== null) {
Expand Down Expand Up @@ -2521,9 +2519,7 @@ function commitMutationEffectsOnFiber(
}

if (flags & Callback && offscreenSubtreeIsHidden) {
const updateQueue: UpdateQueue<
*,
> | null = (finishedWork.updateQueue: any);
const updateQueue: UpdateQueue<mixed> | null = (finishedWork.updateQueue: any);
if (updateQueue !== null) {
deferHiddenCallbacks(updateQueue);
}
Expand Down Expand Up @@ -3015,9 +3011,7 @@ export function reappearLayoutEffects(

// Commit any callbacks that would have fired while the component
// was hidden.
const updateQueue: UpdateQueue<
*,
> | null = (finishedWork.updateQueue: any);
const updateQueue: UpdateQueue<mixed> | null = (finishedWork.updateQueue: any);
if (updateQueue !== null) {
commitHiddenCallbacks(updateQueue, instance);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactInternalTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ type BaseFiberRootProperties = {

// Node returned by Scheduler.scheduleCallback. Represents the next rendering
// task that the root will work on.
callbackNode: *,
callbackNode: any,
callbackPriority: Lane,
eventTimes: LaneMap<number>,
expirationTimes: LaneMap<number>,
Expand Down