From be3e6c3f8b01adddeac505106eae3d6240f0c6e6 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Mon, 8 Dec 2025 13:07:07 -0800 Subject: [PATCH 1/4] [flow] Upgrade from 0.279 -> 0.280 Flow 0.280 introduced stricter type checking for `incompatible-type` errors, requiring additional $FlowFixMe suppressions alongside existing ones. Changes: - Made `QueuingStrategy` properties optional in streams.js - Made all properties optional in Web Animations API types (EffectTiming, KeyframeAnimationOptions, etc.) - Added `$FlowFixMe[incompatible-type]` alongside existing suppressions in multiple files where Flow now reports additional type mismatches --- flow-typed/environments/streams.js | 4 +- flow-typed/environments/web-animations.js | 47 ++++++++++--------- package.json | 4 +- packages/internal-test-utils/internalAct.js | 2 + .../react-client/src/ReactFlightClient.js | 2 + .../src/ReactFlightReplyClient.js | 6 +++ .../react-debug-tools/src/ReactDebugHooks.js | 2 + .../src/client/DOMPropertyOperations.js | 1 + .../src/client/ReactFiberConfigDOM.js | 4 ++ .../src/events/SyntheticEvent.js | 3 ++ .../ReactDOMLegacyServerStreamConfig.js | 1 + .../server/ReactDOMServerExternalRuntime.js | 4 ++ .../react-dom/src/client/ReactDOMClientFB.js | 2 + .../react-dom/src/client/ReactDOMRootFB.js | 2 + packages/react-dom/src/shared/ReactDOM.js | 1 + .../src/ReactFiberCommitWork.js | 1 + .../react-reconciler/src/ReactFiberHooks.js | 3 ++ .../src/ReactFiberWorkLoop.js | 2 + .../src/ReactFlightWebpackReferences.js | 1 + .../src/server/ReactFlightDOMServerNode.js | 1 + packages/react-server/src/ReactFizzHooks.js | 1 + .../react-server/src/ReactFizzNewContext.js | 1 + .../src/ReactFlightActionServer.js | 1 + .../src/ReactFlightReplyServer.js | 3 ++ .../react-server/src/ReactFlightServer.js | 12 +++++ .../src/ReactServerStreamConfigBrowser.js | 2 + .../src/ReactServerStreamConfigBun.js | 4 ++ .../src/ReactServerStreamConfigEdge.js | 1 + .../src/ReactServerStreamConfigNode.js | 1 + packages/react/src/ReactCacheClient.js | 1 + packages/react/src/ReactCacheImpl.js | 2 + packages/scheduler/src/SchedulerMinHeap.js | 1 + packages/scheduler/src/SchedulerProfiling.js | 1 + packages/scheduler/src/forks/Scheduler.js | 5 ++ packages/scheduler/src/forks/SchedulerMock.js | 5 ++ packages/shared/CheckStringCoercion.js | 3 ++ yarn.lock | 30 ++++-------- 37 files changed, 121 insertions(+), 46 deletions(-) diff --git a/flow-typed/environments/streams.js b/flow-typed/environments/streams.js index 17bfae29e61..8e0a17caf95 100644 --- a/flow-typed/environments/streams.js +++ b/flow-typed/environments/streams.js @@ -78,8 +78,8 @@ type PipeToOptions = { }; type QueuingStrategy = { - highWaterMark: number, - size(chunk: ?any): number, + highWaterMark?: number, + size?: (chunk: ?any) => number, ... }; diff --git a/flow-typed/environments/web-animations.js b/flow-typed/environments/web-animations.js index ac059631f7c..6e302acdb40 100644 --- a/flow-typed/environments/web-animations.js +++ b/flow-typed/environments/web-animations.js @@ -29,22 +29,22 @@ type AnimationPlaybackEvent$Init = Event$Init & { }; type BaseComputedKeyframe = {| - composite: CompositeOperationOrAuto, - computedOffset: number, - easing: string, - offset: number | null, + composite?: CompositeOperationOrAuto, + computedOffset?: number, + easing?: string, + offset?: number | null, |}; type BaseKeyframe = {| - composite: CompositeOperationOrAuto, - easing: string, - offset: number | null, + composite?: CompositeOperationOrAuto, + easing?: string, + offset?: number | null, |}; type BasePropertyIndexedKeyframe = {| - composite: CompositeOperationOrAuto | Array, - easing: string | Array, - offset: number | null | Array, + composite?: CompositeOperationOrAuto | Array, + easing?: string | Array, + offset?: number | null | Array, |}; type ComputedEffectTiming = {| @@ -67,28 +67,33 @@ type DocumentTimelineOptions = {| |}; type EffectTiming = {| - direction: PlaybackDirection, - easing: string, - fill: FillMode, - iterations: number, - iterationStart: number, + direction?: PlaybackDirection, + easing?: string, + fill?: FillMode, + iterations?: number, + iterationStart?: number, + delay?: number, + duration?: number | string, + endDelay?: number, |}; type GetAnimationsOptions = {| - pseudoElement: string | null, - subtree: boolean, + pseudoElement?: string | null, + subtree?: boolean, |}; type KeyframeAnimationOptions = {| ...KeyframeEffectOptions, - id: string, - timeline: AnimationTimeline | null, + id?: string, + timeline?: AnimationTimeline | null, + rangeStart?: string, + rangeEnd?: string, |}; type KeyframeEffectOptions = {| ...EffectTiming, - composite: CompositeOperation, - pseudoElement: string | null, + composite?: CompositeOperation, + pseudoElement?: string | null, |}; type Keyframe = { diff --git a/package.json b/package.json index 6969bc14f86..646b0e1dbab 100644 --- a/package.json +++ b/package.json @@ -75,8 +75,8 @@ "eslint-plugin-react-internal": "link:./scripts/eslint-rules", "fbjs-scripts": "^3.0.1", "filesize": "^6.0.1", - "flow-bin": "^0.279.0", - "flow-remove-types": "^2.279.0", + "flow-bin": "^0.280.0", + "flow-remove-types": "^2.280.0", "flow-typed": "^4.1.1", "glob": "^7.1.6", "glob-stream": "^6.1.0", diff --git a/packages/internal-test-utils/internalAct.js b/packages/internal-test-utils/internalAct.js index 1a420bcf203..0bd87ef0457 100644 --- a/packages/internal-test-utils/internalAct.js +++ b/packages/internal-test-utils/internalAct.js @@ -165,6 +165,7 @@ export async function act(scope: () => Thenable): Thenable { } // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] return result; } finally { const depth = actingUpdatesScopeDepth; @@ -287,6 +288,7 @@ export async function serverAct(scope: () => Thenable): Thenable { } // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] return result; } finally { if (typeof process === 'object') { diff --git a/packages/react-client/src/ReactFlightClient.js b/packages/react-client/src/ReactFlightClient.js index 49da30ccf4c..76e6fc8f92b 100644 --- a/packages/react-client/src/ReactFlightClient.js +++ b/packages/react-client/src/ReactFlightClient.js @@ -720,6 +720,7 @@ function triggerErrorOnChunk( const streamChunk: InitializedStreamChunk = (chunk: any); const controller = streamChunk.reason; // $FlowFixMe[incompatible-call]: The error method should accept mixed. + // $FlowFixMe[incompatible-type] controller.error(error); return; } @@ -3207,6 +3208,7 @@ function startReadableStream( error(error: mixed): void { if (previousBlockedChunk === null) { // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] controller.error(error); } else { const blockedChunk = previousBlockedChunk; diff --git a/packages/react-client/src/ReactFlightReplyClient.js b/packages/react-client/src/ReactFlightReplyClient.js index f75f54f4ead..0b0e71b6a3a 100644 --- a/packages/react-client/src/ReactFlightReplyClient.js +++ b/packages/react-client/src/ReactFlightReplyClient.js @@ -535,6 +535,7 @@ export function processReply( if (isArray(value)) { // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] return value; } // TODO: Should we the Object.prototype.toString.call() to test for cross-realm objects? @@ -552,6 +553,7 @@ export function processReply( // $FlowFixMe[prop-missing]: FormData has forEach. value.forEach((originalValue: string | File, originalKey: string) => { // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] data.append(prefix + originalKey, originalValue); }); return serializeFormDataReference(refId); @@ -829,6 +831,7 @@ export function processReply( } modelRoot = model; // $FlowFixMe[incompatible-return] it's not going to be undefined because we'll encode it. + // $FlowFixMe[incompatible-type] return JSON.stringify(model, resolveToJSON); } @@ -855,6 +858,7 @@ export function processReply( formData.set(formFieldPrefix + '0', json); if (pendingParts === 0) { // $FlowFixMe[incompatible-call] this has already been refined. + // $FlowFixMe[incompatible-type] resolve(formData); } } @@ -934,6 +938,7 @@ function defaultEncodeFormAction( // $FlowFixMe[prop-missing] encodedFormData.forEach((value: string | File, key: string) => { // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] prefixedData.append('$ACTION_' + identifierPrefix + ':' + key, value); }); data = prefixedData; @@ -1184,6 +1189,7 @@ function bind(this: Function): Function { if (!referenceClosure) { // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] return FunctionBind.apply(this, arguments); } diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js index db9495a97dd..89f4609e289 100644 --- a/packages/react-debug-tools/src/ReactDebugHooks.js +++ b/packages/react-debug-tools/src/ReactDebugHooks.js @@ -726,9 +726,11 @@ function useActionState( function useHostTransitionStatus(): TransitionStatus { const status = readContext( + // $FlowFixMe[incompatible-type] // $FlowFixMe[prop-missing] `readContext` only needs _currentValue ({ // $FlowFixMe[incompatible-cast] TODO: Incorrect bottom value without access to Fiber config. + // $FlowFixMe[incompatible-type] _currentValue: null, }: ReactContext), ); diff --git a/packages/react-dom-bindings/src/client/DOMPropertyOperations.js b/packages/react-dom-bindings/src/client/DOMPropertyOperations.js index df09445acc5..b783d4225b5 100644 --- a/packages/react-dom-bindings/src/client/DOMPropertyOperations.js +++ b/packages/react-dom-bindings/src/client/DOMPropertyOperations.js @@ -213,6 +213,7 @@ export function setValueForPropertyOnCustomComponent( } } // $FlowFixMe[incompatible-cast] value can't be casted to EventListener. + // $FlowFixMe[incompatible-type] node.addEventListener(eventName, (value: EventListener), useCapture); return; } diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js index e4c45ccc4c3..fde3e6206f0 100644 --- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js +++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js @@ -1455,6 +1455,7 @@ export function applyViewTransitionName( const rects = instance.getClientRects(); if ( // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] countClientRects(rects) === 1 ) { // If the instance has a single client rect, that means that it can be @@ -3203,6 +3204,7 @@ FragmentInstance.prototype.getRootNode = function ( getInstanceFromHostFiber(parentHostFiber); const rootNode = // $FlowFixMe[incompatible-cast] Flow expects Node + // $FlowFixMe[incompatible-type] (parentHostInstance.getRootNode(getRootNodeOptions): Document | ShadowRoot); return rootNode; }; @@ -4649,9 +4651,11 @@ export function getHoistableRoot(container: Container): HoistableRoot { return typeof container.getRootNode === 'function' ? /* $FlowFixMe[incompatible-cast] Flow types this as returning a `Node`, * but it's either a `Document` or `ShadowRoot`. */ + // $FlowFixMe[incompatible-type] (container.getRootNode(): Document | ShadowRoot) : container.nodeType === DOCUMENT_NODE ? // $FlowFixMe[incompatible-cast] We've constrained this to be a Document which satisfies the return type + // $FlowFixMe[incompatible-type] (container: Document) : container.ownerDocument; } diff --git a/packages/react-dom-bindings/src/events/SyntheticEvent.js b/packages/react-dom-bindings/src/events/SyntheticEvent.js index acd50cf8e0c..c51ba896638 100644 --- a/packages/react-dom-bindings/src/events/SyntheticEvent.js +++ b/packages/react-dom-bindings/src/events/SyntheticEvent.js @@ -392,6 +392,7 @@ function getEventKey(nativeEvent: {[propName: string]: mixed}) { if (nativeEvent.type === 'keypress') { const charCode = getEventCharCode( // $FlowFixMe[incompatible-call] unable to narrow to `KeyboardEvent` + // $FlowFixMe[incompatible-type] nativeEvent, ); @@ -464,6 +465,7 @@ const KeyboardEventInterface: EventInterfaceType = { if (event.type === 'keypress') { return getEventCharCode( // $FlowFixMe[incompatible-call] unable to narrow to `KeyboardEvent` + // $FlowFixMe[incompatible-type] event, ); } @@ -488,6 +490,7 @@ const KeyboardEventInterface: EventInterfaceType = { if (event.type === 'keypress') { return getEventCharCode( // $FlowFixMe[incompatible-call] unable to narrow to `KeyboardEvent` + // $FlowFixMe[incompatible-type] event, ); } diff --git a/packages/react-dom-bindings/src/server/ReactDOMLegacyServerStreamConfig.js b/packages/react-dom-bindings/src/server/ReactDOMLegacyServerStreamConfig.js index 54c57685686..24424086a61 100644 --- a/packages/react-dom-bindings/src/server/ReactDOMLegacyServerStreamConfig.js +++ b/packages/react-dom-bindings/src/server/ReactDOMLegacyServerStreamConfig.js @@ -76,6 +76,7 @@ export function byteLengthOfBinaryChunk(chunk: BinaryChunk): number { export function closeWithError(destination: Destination, error: mixed): void { // $FlowFixMe[incompatible-call]: This is an Error object or the destination accepts other types. + // $FlowFixMe[incompatible-type] destination.destroy(error); } diff --git a/packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js b/packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js index 8a13babe2b9..fc85381d5d2 100644 --- a/packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js +++ b/packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js @@ -14,6 +14,7 @@ if (document.body != null) { installFizzInstrObserver(document.body); } // $FlowFixMe[incompatible-cast] + // $FlowFixMe[incompatible-type] handleExistingNodes((document.body: HTMLElement)); } else { // Document must be loading -- body may not exist yet if the fizz external @@ -26,6 +27,7 @@ if (document.body != null) { installFizzInstrObserver(document.body); } // $FlowFixMe[incompatible-cast] + // $FlowFixMe[incompatible-type] handleExistingNodes((document.body: HTMLElement)); // We can call disconnect without takeRecord here, @@ -70,10 +72,12 @@ function installFizzInstrObserver(target: Node) { function handleNode(node_: Node) { // $FlowFixMe[incompatible-cast] + // $FlowFixMe[incompatible-type] if (node_.nodeType !== 1 || !(node_: HTMLElement).dataset) { return; } // $FlowFixMe[incompatible-cast] + // $FlowFixMe[incompatible-type] const node = (node_: HTMLElement); const dataset = node.dataset; if (dataset['rxi'] != null) { diff --git a/packages/react-dom/src/client/ReactDOMClientFB.js b/packages/react-dom/src/client/ReactDOMClientFB.js index 872a4550aa3..a9e5cd7de19 100644 --- a/packages/react-dom/src/client/ReactDOMClientFB.js +++ b/packages/react-dom/src/client/ReactDOMClientFB.js @@ -83,6 +83,7 @@ function createPortal( // TODO: pass ReactDOM portal implementation as third argument // $FlowFixMe[incompatible-return] The Flow type is opaque but there's no way to actually create it. + // $FlowFixMe[incompatible-type] return createPortalImpl(children, container, null, key); } @@ -101,6 +102,7 @@ function flushSyncFromReconciler(fn: (() => R) | void): R | void { } } // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] return flushSyncWithoutWarningIfAlreadyRendering(fn); } diff --git a/packages/react-dom/src/client/ReactDOMRootFB.js b/packages/react-dom/src/client/ReactDOMRootFB.js index 3a0205fe799..8a677a5b82f 100644 --- a/packages/react-dom/src/client/ReactDOMRootFB.js +++ b/packages/react-dom/src/client/ReactDOMRootFB.js @@ -256,6 +256,7 @@ function legacyCreateRootFromDOMContainer( ? container.parentNode : container; // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] listenToAllSupportedEvents(rootContainerElement); flushSyncWork(); @@ -293,6 +294,7 @@ function legacyCreateRootFromDOMContainer( ? container.parentNode : container; // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] listenToAllSupportedEvents(rootContainerElement); // Initial mount should not be batched. diff --git a/packages/react-dom/src/shared/ReactDOM.js b/packages/react-dom/src/shared/ReactDOM.js index f1d48bfacd4..973caabe766 100644 --- a/packages/react-dom/src/shared/ReactDOM.js +++ b/packages/react-dom/src/shared/ReactDOM.js @@ -64,6 +64,7 @@ function createPortal( // TODO: pass ReactDOM portal implementation as third argument // $FlowFixMe[incompatible-return] The Flow type is opaque but there's no way to actually create it. + // $FlowFixMe[incompatible-type] return createPortalImpl(children, container, null, key); } diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js index ecacb0c1585..9c639c187a1 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.js @@ -488,6 +488,7 @@ function commitBeforeMutationEffectsOnFiber( finishedWork.tag === SuspenseComponent && isSuspenseBoundaryBeingHidden(current, finishedWork) && // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] doesFiberContain(finishedWork, focusedInstanceHandle) ) { shouldFireAfterActiveInstanceBlur = true; diff --git a/packages/react-reconciler/src/ReactFiberHooks.js b/packages/react-reconciler/src/ReactFiberHooks.js index 66a390ebb81..f8d474f352a 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.js +++ b/packages/react-reconciler/src/ReactFiberHooks.js @@ -2647,6 +2647,7 @@ function updateEffectImpl( const prevEffect: Effect = currentHook.memoizedState; const prevDeps = prevEffect.deps; // $FlowFixMe[incompatible-call] (@poteto) + // $FlowFixMe[incompatible-type] if (areHookInputsEqual(nextDeps, prevDeps)) { hook.memoizedState = pushSimpleEffect( hookFlags, @@ -2727,6 +2728,7 @@ function mountEvent) => Return>( const ref = {impl: callback}; hook.memoizedState = ref; // $FlowIgnore[incompatible-return] + // $FlowFixMe[incompatible-type] return function eventFn() { if (isInvalidExecutionContextForEventFunction()) { throw new Error( @@ -2744,6 +2746,7 @@ function updateEvent) => Return>( const ref = hook.memoizedState; useEffectEventImpl({ref, nextImpl: callback}); // $FlowIgnore[incompatible-return] + // $FlowIgnore[incompatible-type] return function eventFn() { if (isInvalidExecutionContextForEventFunction()) { throw new Error( diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.js b/packages/react-reconciler/src/ReactFiberWorkLoop.js index f7200458be1..53eb149b3ca 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js @@ -2973,6 +2973,7 @@ function workLoopConcurrent(nonIdle: boolean) { const yieldAfter = now() + (nonIdle ? 25 : 5); do { // $FlowFixMe[incompatible-call] flow doesn't know that now() is side-effect free + // $FlowFixMe[incompatible-type] performUnitOfWork(workInProgress); } while (workInProgress !== null && now() < yieldAfter); } @@ -2983,6 +2984,7 @@ function workLoopConcurrentByScheduler() { // Perform work until Scheduler asks us to yield while (workInProgress !== null && !shouldYield()) { // $FlowFixMe[incompatible-call] flow doesn't know that shouldYield() is side-effect free + // $FlowFixMe[incompatible-type] performUnitOfWork(workInProgress); } } diff --git a/packages/react-server-dom-webpack/src/ReactFlightWebpackReferences.js b/packages/react-server-dom-webpack/src/ReactFlightWebpackReferences.js index de437414ef1..c0f267ece10 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightWebpackReferences.js +++ b/packages/react-server-dom-webpack/src/ReactFlightWebpackReferences.js @@ -64,6 +64,7 @@ const FunctionBind = Function.prototype.bind; const ArraySlice = Array.prototype.slice; function bind(this: ServerReference): any { // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] const newFn = FunctionBind.apply(this, arguments); if (this.$$typeof === SERVER_REFERENCE_TAG) { if (__DEV__) { diff --git a/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerNode.js b/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerNode.js index 5e73d8eb3a5..ebddfd10804 100644 --- a/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerNode.js +++ b/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerNode.js @@ -610,6 +610,7 @@ function decodeReplyFromBusboy( reportGlobalError( response, // $FlowFixMe[incompatible-call] types Error and mixed are incompatible + // $FlowFixMe[incompatible-type] err, ); }); diff --git a/packages/react-server/src/ReactFizzHooks.js b/packages/react-server/src/ReactFizzHooks.js index 119c2a0778f..0ac1859249d 100644 --- a/packages/react-server/src/ReactFizzHooks.js +++ b/packages/react-server/src/ReactFizzHooks.js @@ -547,6 +547,7 @@ export function useEffectEvent) => Return>( callback: F, ): F { // $FlowIgnore[incompatible-return] + // $FlowIgnore[incompatible-type] return throwOnUseEffectEventCall; } diff --git a/packages/react-server/src/ReactFizzNewContext.js b/packages/react-server/src/ReactFizzNewContext.js index 0a9fe3df4c3..f563091401c 100644 --- a/packages/react-server/src/ReactFizzNewContext.js +++ b/packages/react-server/src/ReactFizzNewContext.js @@ -163,6 +163,7 @@ export function switchContext(newSnapshot: ContextSnapshot): void { if (prev !== next) { if (prev === null) { // $FlowFixMe[incompatible-call]: This has to be non-null since it's not equal to prev. + // $FlowFixMe[incompatible-type] pushAllNext(next); } else if (next === null) { popAllPrevious(prev); diff --git a/packages/react-server/src/ReactFlightActionServer.js b/packages/react-server/src/ReactFlightActionServer.js index 9062a6c03da..c591f27499f 100644 --- a/packages/react-server/src/ReactFlightActionServer.js +++ b/packages/react-server/src/ReactFlightActionServer.js @@ -94,6 +94,7 @@ export function decodeAction( body.forEach((value: string | File, key: string) => { if (!key.startsWith('$ACTION_')) { // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] formData.append(key, value); return; } diff --git a/packages/react-server/src/ReactFlightReplyServer.js b/packages/react-server/src/ReactFlightReplyServer.js index 742cae6d201..3cab7f98516 100644 --- a/packages/react-server/src/ReactFlightReplyServer.js +++ b/packages/react-server/src/ReactFlightReplyServer.js @@ -318,6 +318,7 @@ function triggerErrorOnChunk( const streamChunk: InitializedStreamChunk = (chunk: any); const controller = streamChunk.reason; // $FlowFixMe[incompatible-call]: The error method should accept mixed. + // $FlowFixMe[incompatible-type] controller.error(error); return; } @@ -1178,6 +1179,7 @@ function parseReadableStream( error(error: mixed): void { if (previousBlockedChunk === null) { // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] controller.error(error); } else { const blockedChunk = previousBlockedChunk; @@ -1374,6 +1376,7 @@ function parseModelString( backingFormData.forEach((entry: File | string, entryKey: string) => { if (entryKey.startsWith(formPrefix)) { // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] data.append(entryKey.slice(formPrefix.length), entry); } }); diff --git a/packages/react-server/src/ReactFlightServer.js b/packages/react-server/src/ReactFlightServer.js index d5b534adb49..e0e4948348b 100644 --- a/packages/react-server/src/ReactFlightServer.js +++ b/packages/react-server/src/ReactFlightServer.js @@ -394,6 +394,7 @@ function patchConsole(consoleInst: typeof console, methodName: string) { const originalMethod = descriptor.value; const originalName = Object.getOwnPropertyDescriptor( // $FlowFixMe[incompatible-call]: We should be able to get descriptors from any function. + // $FlowFixMe[incompatible-type] originalMethod, 'name', ); @@ -422,6 +423,7 @@ function patchConsole(consoleInst: typeof console, methodName: string) { emitConsoleChunk(request, methodName, owner, env, stack, args); } // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] return originalMethod.apply(this, arguments); }; if (originalName) { @@ -3222,6 +3224,7 @@ function serializeDebugBlob(request: Request, blob: Blob): string { // TODO: Emit the chunk early and refer to it later by dedupe. model.push(entry.value); // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] return reader.read().then(progress).catch(error); } function error(reason: mixed) { @@ -3232,6 +3235,7 @@ function serializeDebugBlob(request: Request, blob: Blob): string { reader.cancel(reason).then(noop, noop); } // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] reader.read().then(progress).catch(error); return '$B' + id.toString(16); } @@ -3270,6 +3274,7 @@ function serializeBlob(request: Request, blob: Blob): string { // TODO: Emit the chunk early and refer to it later by dedupe. model.push(entry.value); // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] return reader.read().then(progress).catch(error); } function error(reason: mixed) { @@ -3305,6 +3310,7 @@ function serializeBlob(request: Request, blob: Blob): string { request.cacheController.signal.addEventListener('abort', abortBlob); // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] reader.read().then(progress).catch(error); return '$B' + newTask.id.toString(16); @@ -3889,6 +3895,7 @@ function renderModelDestructive( } // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] return value; } @@ -5018,6 +5025,7 @@ function renderDebugModel( } // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] return value; } @@ -5158,9 +5166,11 @@ function serializeDebugModel( debugNoOutline = model; try { // $FlowFixMe[incompatible-cast] stringify can return null + // $FlowFixMe[incompatible-type] return (stringify(model, replacer): string); } catch (x) { // $FlowFixMe[incompatible-cast] stringify can return null + // $FlowFixMe[incompatible-type] return (stringify( 'Unknown Value: React could not send it from the server.\n' + x.message, ): string); @@ -5222,9 +5232,11 @@ function emitOutlinedDebugModelChunk( let json: string; try { // $FlowFixMe[incompatible-cast] stringify can return null + // $FlowFixMe[incompatible-type] json = (stringify(model, replacer): string); } catch (x) { // $FlowFixMe[incompatible-cast] stringify can return null + // $FlowFixMe[incompatible-type] json = (stringify( 'Unknown Value: React could not send it from the server.\n' + x.message, ): string); diff --git a/packages/react-server/src/ReactServerStreamConfigBrowser.js b/packages/react-server/src/ReactServerStreamConfigBrowser.js index 41d9aedd005..5fa325be5d4 100644 --- a/packages/react-server/src/ReactServerStreamConfigBrowser.js +++ b/packages/react-server/src/ReactServerStreamConfigBrowser.js @@ -179,6 +179,7 @@ export function closeWithError(destination: Destination, error: mixed): void { // $FlowFixMe[method-unbinding] if (typeof destination.error === 'function') { // $FlowFixMe[incompatible-call]: This is an Error object or the destination accepts other types. + // $FlowFixMe[incompatible-type] destination.error(error); } else { // Earlier implementations doesn't support this method. In that environment you're @@ -197,6 +198,7 @@ export function readAsDataURL(blob: Blob): Promise { return new Promise((resolve, reject) => { const reader = new FileReader(); // $FlowFixMe[incompatible-call]: We always expect a string result with readAsDataURL. + // $FlowFixMe[incompatible-type] reader.onloadend = () => resolve(reader.result); reader.onerror = reject; reader.readAsDataURL(blob); diff --git a/packages/react-server/src/ReactServerStreamConfigBun.js b/packages/react-server/src/ReactServerStreamConfigBun.js index a9079bee43a..06e419320c1 100644 --- a/packages/react-server/src/ReactServerStreamConfigBun.js +++ b/packages/react-server/src/ReactServerStreamConfigBun.js @@ -56,6 +56,7 @@ export function writeChunk( } // $FlowFixMe[incompatible-call]: write() is compatible with both types in Bun + // $FlowFixMe[incompatible-type] destination.write(chunk); } @@ -64,6 +65,7 @@ export function writeChunkAndReturn( chunk: PrecomputedChunk | Chunk | BinaryChunk, ): boolean { // $FlowFixMe[incompatible-call]: write() is compatible with both types in Bun + // $FlowFixMe[incompatible-type] return !!destination.write(chunk); } @@ -101,12 +103,14 @@ export function closeWithError(destination: Destination, error: mixed): void { // $FlowFixMe[method-unbinding] if (typeof destination.error === 'function') { // $FlowFixMe[incompatible-call]: This is an Error object or the destination accepts other types. + // $FlowFixMe[incompatible-type] destination.error(error); // $FlowFixMe[incompatible-use] // $FlowFixMe[method-unbinding] } else if (typeof destination.destroy === 'function') { // $FlowFixMe[incompatible-call]: This is an Error object or the destination accepts other types. + // $FlowFixMe[incompatible-type] destination.destroy(error); // $FlowFixMe[incompatible-use] diff --git a/packages/react-server/src/ReactServerStreamConfigEdge.js b/packages/react-server/src/ReactServerStreamConfigEdge.js index 90affdc6b8a..cdf4a372b8c 100644 --- a/packages/react-server/src/ReactServerStreamConfigEdge.js +++ b/packages/react-server/src/ReactServerStreamConfigEdge.js @@ -166,6 +166,7 @@ export function closeWithError(destination: Destination, error: mixed): void { // $FlowFixMe[method-unbinding] if (typeof destination.error === 'function') { // $FlowFixMe[incompatible-call]: This is an Error object or the destination accepts other types. + // $FlowFixMe[incompatible-type] destination.error(error); } else { // Earlier implementations doesn't support this method. In that environment you're diff --git a/packages/react-server/src/ReactServerStreamConfigNode.js b/packages/react-server/src/ReactServerStreamConfigNode.js index 90609da2c45..82396064e50 100644 --- a/packages/react-server/src/ReactServerStreamConfigNode.js +++ b/packages/react-server/src/ReactServerStreamConfigNode.js @@ -232,6 +232,7 @@ export function byteLengthOfBinaryChunk(chunk: BinaryChunk): number { export function closeWithError(destination: Destination, error: mixed): void { // $FlowFixMe[incompatible-call]: This is an Error object or the destination accepts other types. + // $FlowFixMe[incompatible-type] destination.destroy(error); } diff --git a/packages/react/src/ReactCacheClient.js b/packages/react/src/ReactCacheClient.js index ef1e8d6d1da..8b029e7e43f 100644 --- a/packages/react/src/ReactCacheClient.js +++ b/packages/react/src/ReactCacheClient.js @@ -28,6 +28,7 @@ function noopCache, T>(fn: (...A) => T): (...A) => T { // accidentally depend on those details. return function () { // $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code. + // $FlowFixMe[incompatible-type] return fn.apply(null, arguments); }; } diff --git a/packages/react/src/ReactCacheImpl.js b/packages/react/src/ReactCacheImpl.js index 2ff7431fc51..d6e0491b6c3 100644 --- a/packages/react/src/ReactCacheImpl.js +++ b/packages/react/src/ReactCacheImpl.js @@ -58,6 +58,7 @@ export function cache, T>(fn: (...A) => T): (...A) => T { if (!dispatcher) { // If there is no dispatcher, then we treat this as not being cached. // $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code. + // $FlowFixMe[incompatible-type] return fn.apply(null, arguments); } const fnMap: WeakMap> = dispatcher.getCacheForType( @@ -112,6 +113,7 @@ export function cache, T>(fn: (...A) => T): (...A) => T { } try { // $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code. + // $FlowFixMe[incompatible-type] const result = fn.apply(null, arguments); const terminatedNode: TerminatedCacheNode = (cacheNode: any); terminatedNode.s = TERMINATED; diff --git a/packages/scheduler/src/SchedulerMinHeap.js b/packages/scheduler/src/SchedulerMinHeap.js index da997bad357..c2e33d00564 100644 --- a/packages/scheduler/src/SchedulerMinHeap.js +++ b/packages/scheduler/src/SchedulerMinHeap.js @@ -34,6 +34,7 @@ export function pop(heap: Heap): T | null { // $FlowFixMe[incompatible-type] heap[0] = last; // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] siftDown(heap, last, 0); } return first; diff --git a/packages/scheduler/src/SchedulerProfiling.js b/packages/scheduler/src/SchedulerProfiling.js index 9fdd5906af6..b7cc640c34a 100644 --- a/packages/scheduler/src/SchedulerProfiling.js +++ b/packages/scheduler/src/SchedulerProfiling.js @@ -48,6 +48,7 @@ function logEvent(entries: Array) { } const newEventLog = new Int32Array(eventLogSize * 4); // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] newEventLog.set(eventLog); eventLogBuffer = newEventLog.buffer; eventLog = newEventLog; diff --git a/packages/scheduler/src/forks/Scheduler.js b/packages/scheduler/src/forks/Scheduler.js index 88239b71067..8afdb15b2b1 100644 --- a/packages/scheduler/src/forks/Scheduler.js +++ b/packages/scheduler/src/forks/Scheduler.js @@ -164,6 +164,7 @@ function flushWork(initialTime: number) { if (currentTask !== null) { const currentTime = getCurrentTime(); // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] markTaskErrored(currentTask, currentTime); // $FlowFixMe[incompatible-use] found when upgrading Flow currentTask.isQueued = false; @@ -207,6 +208,7 @@ function workLoop(initialTime: number) { const didUserCallbackTimeout = currentTask.expirationTime <= currentTime; if (enableProfiling) { // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] markTaskRun(currentTask, currentTime); } const continuationCallback = callback(didUserCallbackTimeout); @@ -218,6 +220,7 @@ function workLoop(initialTime: number) { currentTask.callback = continuationCallback; if (enableProfiling) { // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] markTaskYield(currentTask, currentTime); } advanceTimers(currentTime); @@ -225,6 +228,7 @@ function workLoop(initialTime: number) { } else { if (enableProfiling) { // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] markTaskCompleted(currentTask, currentTime); // $FlowFixMe[incompatible-use] found when upgrading Flow currentTask.isQueued = false; @@ -310,6 +314,7 @@ function unstable_next(eventHandler: () => T): T { function unstable_wrapCallback) => mixed>(callback: T): T { var parentPriorityLevel = currentPriorityLevel; // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] // $FlowFixMe[missing-this-annot] return function () { // This is a fork of runWithPriority, inlined for performance. diff --git a/packages/scheduler/src/forks/SchedulerMock.js b/packages/scheduler/src/forks/SchedulerMock.js index cf76126410e..e478700064f 100644 --- a/packages/scheduler/src/forks/SchedulerMock.js +++ b/packages/scheduler/src/forks/SchedulerMock.js @@ -164,6 +164,7 @@ function flushWork(hasTimeRemaining: boolean, initialTime: number) { if (currentTask !== null) { const currentTime = getCurrentTime(); // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] markTaskErrored(currentTask, currentTime); // $FlowFixMe[incompatible-use] found when upgrading Flow currentTask.isQueued = false; @@ -208,6 +209,7 @@ function workLoop(hasTimeRemaining: boolean, initialTime: number): boolean { const didUserCallbackTimeout = currentTask.expirationTime <= currentTime; if (enableProfiling) { // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] markTaskRun(currentTask, currentTime); } const continuationCallback = callback(didUserCallbackTimeout); @@ -219,6 +221,7 @@ function workLoop(hasTimeRemaining: boolean, initialTime: number): boolean { currentTask.callback = continuationCallback; if (enableProfiling) { // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] markTaskYield(currentTask, currentTime); } advanceTimers(currentTime); @@ -234,6 +237,7 @@ function workLoop(hasTimeRemaining: boolean, initialTime: number): boolean { } else { if (enableProfiling) { // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] markTaskCompleted(currentTask, currentTime); // $FlowFixMe[incompatible-use] found when upgrading Flow currentTask.isQueued = false; @@ -313,6 +317,7 @@ function unstable_next(eventHandler: () => T): T { function unstable_wrapCallback) => mixed>(callback: T): T { var parentPriorityLevel = currentPriorityLevel; // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] // $FlowFixMe[missing-this-annot] return function () { // This is a fork of runWithPriority, inlined for performance. diff --git a/packages/shared/CheckStringCoercion.js b/packages/shared/CheckStringCoercion.js index a186d6755d9..b117b7acfe5 100644 --- a/packages/shared/CheckStringCoercion.js +++ b/packages/shared/CheckStringCoercion.js @@ -18,6 +18,7 @@ */ // $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible. +// $FlowFixMe[incompatible-type] function typeName(value: mixed): string { if (__DEV__) { // toStringTag is needed for namespaced types like Temporal.Instant @@ -27,11 +28,13 @@ function typeName(value: mixed): string { (value: any).constructor.name || 'Object'; // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] return type; } } // $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible. +// $FlowFixMe[incompatible-type] function willCoercionThrow(value: mixed): boolean { if (__DEV__) { try { diff --git a/yarn.lock b/yarn.lock index bfce9322918..38d280c8b84 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9222,17 +9222,17 @@ flatted@^3.2.9: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.1.tgz#21db470729a6734d4997002f439cb308987f567a" integrity sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw== -flow-bin@^0.279.0: - version "0.279.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.279.0.tgz#06e502a51d735083d715ef769f43bdcb0fc2bb61" - integrity sha512-Xf0T82atOcEf5auHvJfUF+wWIxieBuUJZBu2hlAizdhAzwqSJic74ZLaL6N5SsE0SY9PxPf3Z/lBU7iRpRa9Lw== +flow-bin@^0.280.0: + version "0.280.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.280.0.tgz#73db532b4ea072a20a47277a38c0ab9f4f4600e6" + integrity sha512-7WHDjleRd6KDggSYovdrNSz1xMM9HKSI3ajHF3xMmWaETxx3SHnl60cclW6mPm3z+0FUVQSr7XFLiGSW3Zkq7Q== -flow-remove-types@^2.279.0: - version "2.279.0" - resolved "https://registry.yarnpkg.com/flow-remove-types/-/flow-remove-types-2.279.0.tgz#3a3388d9158eba0f82c40d80d31d9640b883a3f5" - integrity sha512-bPFloMR/A2b/r/sIsf7Ix0LaMicCJNjwhXc4xEEQVzJCIz5u7C7XDaEOXOiqveKlCYK7DcBNn6R01Cbbc9gsYA== +flow-remove-types@^2.280.0: + version "2.293.0" + resolved "https://registry.yarnpkg.com/flow-remove-types/-/flow-remove-types-2.293.0.tgz#ff63c979bbf0da625cc5a9a33af546261ee23307" + integrity sha512-UoF3jXBZ3YH1SYSMq+bLchQ7HGOBykPHThCyl7FdWspCzcW1qQ2nVbkbv5fclzLOzlEZ42c8LpeliAC0tqORzA== dependencies: - hermes-parser "0.29.1" + hermes-parser "0.32.0" pirates "^3.0.2" vlq "^0.2.1" @@ -10114,23 +10114,11 @@ hermes-estree@0.25.1: resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.25.1.tgz#6aeec17d1983b4eabf69721f3aa3eb705b17f480" integrity sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw== -hermes-estree@0.29.1: - version "0.29.1" - resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.29.1.tgz#043c7db076e0e8ef8c5f6ed23828d1ba463ebcc5" - integrity sha512-jl+x31n4/w+wEqm0I2r4CMimukLbLQEYpisys5oCre611CI5fc9TxhqkBBCJ1edDG4Kza0f7CgNz8xVMLZQOmQ== - hermes-estree@0.32.0: version "0.32.0" resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.32.0.tgz#bb7da6613ab8e67e334a1854ea1e209f487d307b" integrity sha512-KWn3BqnlDOl97Xe1Yviur6NbgIZ+IP+UVSpshlZWkq+EtoHg6/cwiDj/osP9PCEgFE15KBm1O55JRwbMEm5ejQ== -hermes-parser@0.29.1: - version "0.29.1" - resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.29.1.tgz#436b24bcd7bb1e71f92a04c396ccc0716c288d56" - integrity sha512-xBHWmUtRC5e/UL0tI7Ivt2riA/YBq9+SiYFU7C1oBa/j2jYGlIF9043oak1F47ihuDIxQ5nbsKueYJDRY02UgA== - dependencies: - hermes-estree "0.29.1" - hermes-parser@0.32.0, hermes-parser@^0.32.0: version "0.32.0" resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.32.0.tgz#7916984ef6fdce62e7415d354cf35392061cd303" From 0d36faf38cb57628319d1005e212e9ec5f1f1590 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Mon, 8 Dec 2025 13:07:07 -0800 Subject: [PATCH 2/4] [flow] Upgrade from 0.280 -> 0.281 Major changes in Flow 0.281: - $FlowFixMe comments now require explicit error codes (e.g., $FlowFixMe[incompatible-type]) - Changed all bare $FlowFixMe to include appropriate error codes - Changed $FlowIgnore to $FlowFixMe where needed - Fixed stream types to have cancel() return Promise instead of void - Added pseudoElement property to KeyframeEffect type - Added suppressions for Proxy handler variance issues - Fixed various type errors across the codebase --- flow-typed/environments/streams.js | 8 +++--- flow-typed/environments/web-animations.js | 1 + package.json | 4 +-- .../src/ReactClientConsoleConfigBrowser.js | 5 ++-- .../src/ReactClientConsoleConfigPlain.js | 5 ++-- .../src/ReactClientConsoleConfigServer.js | 5 ++-- .../react-client/src/ReactFlightClient.js | 14 +++++----- .../src/ReactFlightClientStreamConfigNode.js | 2 +- .../src/client/ReactFiberConfigDOM.js | 26 +++++++++---------- .../src/client/estimateBandwidth.js | 3 ++- .../src/server/ReactFizzConfigDOM.js | 2 +- .../ReactDOMDefaultTransitionIndicator.js | 14 +++++----- .../react-dom/src/test-utils/FizzTestUtils.js | 2 +- .../src/ReactCapturedValue.js | 2 ++ .../react-reconciler/src/ReactChildFiber.js | 6 +++-- .../src/ReactFiberCommitEffects.js | 11 ++++---- .../react-reconciler/src/ReactFiberHooks.js | 8 +++--- .../src/ReactFiberNewContext.js | 8 ++++-- .../src/ReactFiberPerformanceTrack.js | 8 ++++++ .../src/ReactFiberThenable.js | 1 + .../src/ReactFlightWebpackNodeLoader.js | 5 ++-- .../src/ReactFlightWebpackReferences.js | 6 +++++ .../src/server/ReactFlightDOMServerNode.js | 8 +++--- packages/react-server/src/ReactFizzHooks.js | 12 ++++----- packages/react-server/src/ReactFizzServer.js | 24 +++++++++-------- .../src/ReactFlightActionServer.js | 6 +++-- .../react-server/src/ReactFlightServer.js | 21 +++++++-------- .../src/ReactFlightServerConfigDebugNode.js | 2 +- .../src/ReactServerConsoleConfigBrowser.js | 2 +- .../src/ReactServerConsoleConfigPlain.js | 2 +- .../src/ReactServerConsoleConfigServer.js | 2 +- .../src/ReactSharedInternalsServer.js | 4 ++- packages/react/src/ReactChildren.js | 2 +- packages/react/src/ReactLazy.js | 15 +++++++---- yarn.lock | 10 +++---- 35 files changed, 148 insertions(+), 108 deletions(-) diff --git a/flow-typed/environments/streams.js b/flow-typed/environments/streams.js index 8e0a17caf95..ce7ab0b394e 100644 --- a/flow-typed/environments/streams.js +++ b/flow-typed/environments/streams.js @@ -42,7 +42,7 @@ declare class ReadableStreamReader { closed: boolean; - cancel(reason: string): void; + cancel(reason: mixed): Promise; read(): Promise<{ value: ?any, done: boolean, @@ -57,7 +57,7 @@ declare interface UnderlyingSource { start?: (controller: ReadableStreamController) => ?Promise; pull?: (controller: ReadableStreamController) => ?Promise; - cancel?: (reason: string) => ?Promise; + cancel?: (reason: mixed) => ?Promise; } declare class TransformStream { @@ -91,7 +91,7 @@ declare class ReadableStream { locked: boolean; - cancel(reason: string): void; + cancel(reason: mixed): Promise; getReader(): ReadableStreamReader; pipeThrough(transform: PipeThroughTransformStream, options: ?any): void; pipeTo(dest: WritableStream, options: ?PipeToOptions): Promise; @@ -106,7 +106,7 @@ declare interface UnderlyingSink { autoAllocateChunkSize?: number; type?: string; - abort?: (reason: string) => ?Promise; + abort?: (reason: mixed) => ?Promise; close?: (controller: WritableStreamController) => ?Promise; start?: (controller: WritableStreamController) => ?Promise; write?: (chunk: any, controller: WritableStreamController) => ?Promise; diff --git a/flow-typed/environments/web-animations.js b/flow-typed/environments/web-animations.js index 6e302acdb40..92092d2c9dd 100644 --- a/flow-typed/environments/web-animations.js +++ b/flow-typed/environments/web-animations.js @@ -182,6 +182,7 @@ declare class KeyframeEffect extends AnimationEffect { constructor(source: KeyframeEffect): void; target: Element | null; + pseudoElement: string | null; composite: CompositeOperation; // This is actually web-animations-2 iterationComposite: IterationCompositeOperation; diff --git a/package.json b/package.json index 646b0e1dbab..af3b4b1e624 100644 --- a/package.json +++ b/package.json @@ -75,8 +75,8 @@ "eslint-plugin-react-internal": "link:./scripts/eslint-rules", "fbjs-scripts": "^3.0.1", "filesize": "^6.0.1", - "flow-bin": "^0.280.0", - "flow-remove-types": "^2.280.0", + "flow-bin": "^0.281.0", + "flow-remove-types": "^2.281.0", "flow-typed": "^4.1.1", "glob": "^7.1.6", "glob-stream": "^6.1.0", diff --git a/packages/react-client/src/ReactClientConsoleConfigBrowser.js b/packages/react-client/src/ReactClientConsoleConfigBrowser.js index f67e4afa0c4..3a8625177ea 100644 --- a/packages/react-client/src/ReactClientConsoleConfigBrowser.js +++ b/packages/react-client/src/ReactClientConsoleConfigBrowser.js @@ -35,7 +35,7 @@ export function bindToConsole( case 'groupEnd': case 'table': { // These methods cannot be colorized because they don't take a formatting string. - // $FlowFixMe + // $FlowFixMe[incompatible-type] return bind.apply(console[methodName], [console].concat(args)); // eslint-disable-line react-internal/no-production-logging } case 'assert': { @@ -68,6 +68,7 @@ export function bindToConsole( // The "this" binding in the "bind"; newArgs.unshift(console); - // $FlowFixMe + // $FlowFixMe[incompatible-type] + // $FlowFixMe[invalid-computed-prop] return bind.apply(console[methodName], newArgs); // eslint-disable-line react-internal/no-production-logging } diff --git a/packages/react-client/src/ReactClientConsoleConfigPlain.js b/packages/react-client/src/ReactClientConsoleConfigPlain.js index ee4c87ca613..3841007b492 100644 --- a/packages/react-client/src/ReactClientConsoleConfigPlain.js +++ b/packages/react-client/src/ReactClientConsoleConfigPlain.js @@ -25,7 +25,7 @@ export function bindToConsole( case 'groupEnd': case 'table': { // These methods cannot be colorized because they don't take a formatting string. - // $FlowFixMe + // $FlowFixMe[incompatible-type] return bind.apply(console[methodName], [console].concat(args)); // eslint-disable-line react-internal/no-production-logging } case 'assert': { @@ -49,6 +49,7 @@ export function bindToConsole( // The "this" binding in the "bind"; newArgs.unshift(console); - // $FlowFixMe + // $FlowFixMe[incompatible-type] + // $FlowFixMe[invalid-computed-prop] return bind.apply(console[methodName], newArgs); // eslint-disable-line react-internal/no-production-logging } diff --git a/packages/react-client/src/ReactClientConsoleConfigServer.js b/packages/react-client/src/ReactClientConsoleConfigServer.js index 6e69ef12a3c..6663549fbd7 100644 --- a/packages/react-client/src/ReactClientConsoleConfigServer.js +++ b/packages/react-client/src/ReactClientConsoleConfigServer.js @@ -36,7 +36,7 @@ export function bindToConsole( case 'groupEnd': case 'table': { // These methods cannot be colorized because they don't take a formatting string. - // $FlowFixMe + // $FlowFixMe[incompatible-type] return bind.apply(console[methodName], [console].concat(args)); // eslint-disable-line react-internal/no-production-logging } case 'assert': { @@ -69,6 +69,7 @@ export function bindToConsole( // The "this" binding in the "bind"; newArgs.unshift(console); - // $FlowFixMe + // $FlowFixMe[incompatible-type] + // $FlowFixMe[invalid-computed-prop] return bind.apply(console[methodName], newArgs); // eslint-disable-line react-internal/no-production-logging } diff --git a/packages/react-client/src/ReactFlightClient.js b/packages/react-client/src/ReactFlightClient.js index 76e6fc8f92b..4beb9fe6617 100644 --- a/packages/react-client/src/ReactFlightClient.js +++ b/packages/react-client/src/ReactFlightClient.js @@ -283,12 +283,12 @@ ReactPromise.prototype.then = function ( const rejectCallback = reject; const wrapperPromise: Promise = new Promise((res, rej) => { resolve = value => { - // $FlowFixMe + // $FlowFixMe[prop-missing] wrapperPromise._debugInfo = this._debugInfo; res(value); }; reject = reason => { - // $FlowFixMe + // $FlowFixMe[prop-missing] wrapperPromise._debugInfo = this._debugInfo; rej(reason); }; @@ -3922,7 +3922,7 @@ function initializeDebugInfo( } if (debugInfo.owner == null && response._debugRootOwner != null) { const componentInfoOrAsyncInfo: ReactComponentInfo | ReactAsyncInfo = - // $FlowFixMe: By narrowing `owner` to `null`, we narrowed `debugInfo` to `ReactComponentInfo` + // $FlowFixMe[incompatible-type]: By narrowing `owner` to `null`, we narrowed `debugInfo` to `ReactComponentInfo` debugInfo; // $FlowFixMe[cannot-write] componentInfoOrAsyncInfo.owner = response._debugRootOwner; @@ -4268,7 +4268,7 @@ function logComponentInfo( childrenEndTime: number, isLastComponent: boolean, ): void { - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-use]: Refined. if ( isLastComponent && root.status === ERRORED && @@ -4447,7 +4447,7 @@ function flushComponentPerformance( if (componentEndTime > childrenEndTime) { childrenEndTime = componentEndTime; } - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. const componentInfo: ReactComponentInfo = candidateInfo; logComponentInfo( response, @@ -4471,7 +4471,7 @@ function flushComponentPerformance( if (endTime > childrenEndTime) { childrenEndTime = endTime; } - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. const asyncInfo: ReactAsyncInfo = candidateInfo; const env = response._rootEnvironmentName; const promise = asyncInfo.awaited.value; @@ -4534,7 +4534,7 @@ function flushComponentPerformance( if (componentEndTime > childrenEndTime) { childrenEndTime = componentEndTime; } - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. const componentInfo: ReactComponentInfo = candidateInfo; const env = response._rootEnvironmentName; logComponentAborted( diff --git a/packages/react-client/src/ReactFlightClientStreamConfigNode.js b/packages/react-client/src/ReactFlightClientStreamConfigNode.js index f544759ccce..c043447398c 100644 --- a/packages/react-client/src/ReactFlightClientStreamConfigNode.js +++ b/packages/react-client/src/ReactFlightClientStreamConfigNode.js @@ -15,7 +15,7 @@ export function createStringDecoder(): StringDecoder { return new TextDecoder(); } -const decoderOptions = {stream: true}; +const decoderOptions: {stream?: boolean, ...} = {stream: true}; export function readPartialStringChunk( decoder: StringDecoder, diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js index fde3e6206f0..f64d0eaebc1 100644 --- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js +++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js @@ -1712,11 +1712,11 @@ function moveOutOfViewport( // while still letting it paint its "old" state to a snapshot. const transform = getComputedTransform(originalStyle); // Clear the long form properties. - // $FlowFixMe + // $FlowFixMe[prop-missing] element.style.translate = 'none'; - // $FlowFixMe + // $FlowFixMe[prop-missing] element.style.scale = 'none'; - // $FlowFixMe + // $FlowFixMe[prop-missing] element.style.rotate = 'none'; // Apply a translate to move it way out of the viewport. This is applied first // so that it is in the coordinate space of the parent and not after applying @@ -1799,7 +1799,7 @@ export function cloneRootViewTransitionContainer( if (getComputedStyle(positionedAncestor).position !== 'static') { break; } - // $FlowFixMe: This is refined. + // $FlowFixMe[incompatible-type]: This is refined. positionedAncestor = positionedAncestor.parentNode; } @@ -2005,7 +2005,6 @@ function cancelAllViewTransitionAnimations(scope: Element) { for (let i = 0; i < animations.length; i++) { const anim = animations[i]; const effect: KeyframeEffect = (anim.effect: any); - // $FlowFixMe const pseudo: ?string = effect.pseudoElement; if ( pseudo != null && @@ -2219,7 +2218,6 @@ export function startViewTransition( for (let i = 0; i < animations.length; i++) { const animation = animations[i]; const effect: KeyframeEffect = (animation.effect: any); - // $FlowFixMe const pseudoElement: ?string = effect.pseudoElement; if ( pseudoElement != null && @@ -2260,13 +2258,13 @@ export function startViewTransition( height !== undefined ) { // Replace the keyframes with ones that don't animate the width/height. - // $FlowFixMe + // $FlowFixMe[incompatible-type] effect.setKeyframes(keyframes); // Read back the new animation to see what the underlying width/height of the pseudo-element was. const computedStyle = getComputedStyle( - // $FlowFixMe + // $FlowFixMe[incompatible-type] effect.target, - // $FlowFixMe + // $FlowFixMe[incompatible-type] effect.pseudoElement, ); if ( @@ -2281,7 +2279,7 @@ export function startViewTransition( const last = keyframes[keyframes.length - 1]; last.width = width; last.height = height; - // $FlowFixMe + // $FlowFixMe[incompatible-type] effect.setKeyframes(keyframes); } } @@ -2563,7 +2561,6 @@ export function startGestureTransition( let longestDuration = 0; for (let i = 0; i < animations.length; i++) { const effect: KeyframeEffect = (animations[i].effect: any); - // $FlowFixMe const pseudoElement: ?string = effect.pseudoElement; if (pseudoElement == null) { } else if (pseudoElement.startsWith('::view-transition')) { @@ -2595,7 +2592,6 @@ export function startGestureTransition( continue; } const effect: KeyframeEffect = (anim.effect: any); - // $FlowFixMe const pseudoElement: ?string = effect.pseudoElement; if ( pseudoElement != null && @@ -2655,7 +2651,7 @@ export function startGestureTransition( } animateGesture( effect.getKeyframes(), - // $FlowFixMe: Always documentElement atm. + // $FlowFixMe[incompatible-type]: Always documentElement atm. effect.target, pseudoElement, timeline, @@ -2682,7 +2678,7 @@ export function startGestureTransition( const pseudoElementName = '::view-transition-group' + groupName; animateGesture( [{}, {}], - // $FlowFixMe: Always documentElement atm. + // $FlowFixMe[incompatible-type]: Always documentElement atm. effect.target, pseudoElementName, timeline, @@ -4966,12 +4962,14 @@ function preinitStyle( } // Construct a Resource and cache it + // $FlowFixMe[incompatible-type] resource = { type: 'stylesheet', instance, count: 1, state, }; + // $FlowFixMe[incompatible-type] styles.set(key, resource); return; } diff --git a/packages/react-dom-bindings/src/client/estimateBandwidth.js b/packages/react-dom-bindings/src/client/estimateBandwidth.js index 4b143a5b562..7d1e542112d 100644 --- a/packages/react-dom-bindings/src/client/estimateBandwidth.js +++ b/packages/react-dom-bindings/src/client/estimateBandwidth.js @@ -98,7 +98,8 @@ export default function estimateBandwidth(): number { // Fallback to the navigator.connection estimate if available // $FlowFixMe[prop-missing] if (navigator.connection) { - // $FlowFixMe + // $FlowFixMe[prop-missing] + // $FlowFixMe[incompatible-use] const downlink: ?number = navigator.connection.downlink; if (typeof downlink === 'number') { return downlink; diff --git a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js index a93c32a947f..9c6eb622e12 100644 --- a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js +++ b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js @@ -3366,7 +3366,7 @@ function pushImg( // reenter this branch in a second pass for duplicate img hrefs. promotablePreloads.delete(key); - // $FlowFixMe - Flow should understand that this is a Resource if the condition was true + // $FlowFixMe[incompatible-call] - Flow should understand that this is a Resource if the condition was true renderState.highImagePreloads.add(resource); } } else if (!resumableState.imageResources.hasOwnProperty(key)) { diff --git a/packages/react-dom/src/client/ReactDOMDefaultTransitionIndicator.js b/packages/react-dom/src/client/ReactDOMDefaultTransitionIndicator.js index 37661849cad..751245a40df 100644 --- a/packages/react-dom/src/client/ReactDOMDefaultTransitionIndicator.js +++ b/packages/react-dom/src/client/ReactDOMDefaultTransitionIndicator.js @@ -43,11 +43,12 @@ export function defaultOnDefaultTransitionIndicator(): void | (() => void) { } } - // $FlowFixMe + // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] navigation.addEventListener('navigate', handleNavigate); - // $FlowFixMe + // $FlowFixMe[incompatible-call] navigation.addEventListener('navigatesuccess', handleNavigateComplete); - // $FlowFixMe + // $FlowFixMe[incompatible-call] navigation.addEventListener('navigateerror', handleNavigateComplete); function startFakeNavigation() { @@ -76,11 +77,12 @@ export function defaultOnDefaultTransitionIndicator(): void | (() => void) { return function () { isCancelled = true; - // $FlowFixMe + // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] navigation.removeEventListener('navigate', handleNavigate); - // $FlowFixMe + // $FlowFixMe[incompatible-call] navigation.removeEventListener('navigatesuccess', handleNavigateComplete); - // $FlowFixMe + // $FlowFixMe[incompatible-call] navigation.removeEventListener('navigateerror', handleNavigateComplete); if (pendingResolve !== null) { pendingResolve(); diff --git a/packages/react-dom/src/test-utils/FizzTestUtils.js b/packages/react-dom/src/test-utils/FizzTestUtils.js index 4d8b6cadbab..aabaf9306b6 100644 --- a/packages/react-dom/src/test-utils/FizzTestUtils.js +++ b/packages/react-dom/src/test-utils/FizzTestUtils.js @@ -95,7 +95,7 @@ async function executeScript(script: Element) { } try { - // $FlowFixMe + // $FlowFixMe[unsupported-syntax] require(scriptSrc); } catch (x) { const event = new window.ErrorEvent('error', {error: x}); diff --git a/packages/react-reconciler/src/ReactCapturedValue.js b/packages/react-reconciler/src/ReactCapturedValue.js index d53489cc3b7..feb0a9f0752 100644 --- a/packages/react-reconciler/src/ReactCapturedValue.js +++ b/packages/react-reconciler/src/ReactCapturedValue.js @@ -56,7 +56,9 @@ export function createCapturedValueFromError( stack: stack, }; if (typeof stack === 'string') { + // $FlowFixMe[incompatible-type] CapturedStacks.set(value, captured); } + // $FlowFixMe[incompatible-type] return captured; } diff --git a/packages/react-reconciler/src/ReactChildFiber.js b/packages/react-reconciler/src/ReactChildFiber.js index 2a726447263..c5aeebeebf6 100644 --- a/packages/react-reconciler/src/ReactChildFiber.js +++ b/packages/react-reconciler/src/ReactChildFiber.js @@ -2224,10 +2224,12 @@ export function validateSuspenseListChildren( enableAsyncIterableChildren && children.$$typeof === REACT_ELEMENT_TYPE && typeof children.type === 'function' && - // $FlowFixMe + // $FlowFixMe[incompatible-use] + // $FlowFixMe[method-unbinding] (Object.prototype.toString.call(children.type) === '[object GeneratorFunction]' || - // $FlowFixMe + // $FlowFixMe[incompatible-use] + // $FlowFixMe[method-unbinding] Object.prototype.toString.call(children.type) === '[object AsyncGeneratorFunction]') ) { diff --git a/packages/react-reconciler/src/ReactFiberCommitEffects.js b/packages/react-reconciler/src/ReactFiberCommitEffects.js index f7e20fe9261..ba4fbe29763 100644 --- a/packages/react-reconciler/src/ReactFiberCommitEffects.js +++ b/packages/react-reconciler/src/ReactFiberCommitEffects.js @@ -199,7 +199,7 @@ export function commitHookEffectListMount( addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).'; - // $FlowFixMe (@poteto) this check is safe on arbitrary non-null/void objects + // $FlowFixMe[incompatible-type] (@poteto) this check is safe on arbitrary non-null/void objects } else if (typeof destroy.then === 'function') { addendum = '\n\nIt looks like you wrote ' + @@ -924,7 +924,8 @@ function safelyCallDestroy( ); } else { try { - // $FlowFixMe(incompatible-call) Already bound to resource + // $FlowFixMe[incompatible-call] Already bound to resource + // $FlowFixMe[incompatible-type] destroy_(); } catch (error) { captureCommitPhaseError(current, nearestMountedAncestor, error); @@ -951,11 +952,11 @@ function commitProfiler( onRender( id, phase, - // $FlowFixMe: This should be always a number in profiling mode + // $FlowFixMe[incompatible-type]: This should be always a number in profiling mode finishedWork.actualDuration, - // $FlowFixMe: This should be always a number in profiling mode + // $FlowFixMe[incompatible-type]: This should be always a number in profiling mode finishedWork.treeBaseDuration, - // $FlowFixMe: This should be always a number in profiling mode + // $FlowFixMe[incompatible-type]: This should be always a number in profiling mode finishedWork.actualStartTime, commitStartTime, ); diff --git a/packages/react-reconciler/src/ReactFiberHooks.js b/packages/react-reconciler/src/ReactFiberHooks.js index f8d474f352a..b04f68da7af 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.js +++ b/packages/react-reconciler/src/ReactFiberHooks.js @@ -416,9 +416,9 @@ function warnIfAsyncClientComponent(Component: Function) { // for transpiled async functions. Neither mechanism is completely // bulletproof but together they cover the most common cases. const isAsyncFunction = - // $FlowIgnore[method-unbinding] + // $FlowFixMe[method-unbinding] Object.prototype.toString.call(Component) === '[object AsyncFunction]' || - // $FlowIgnore[method-unbinding] + // $FlowFixMe[method-unbinding] Object.prototype.toString.call(Component) === '[object AsyncGeneratorFunction]'; if (isAsyncFunction) { @@ -2745,8 +2745,8 @@ function updateEvent) => Return>( const hook = updateWorkInProgressHook(); const ref = hook.memoizedState; useEffectEventImpl({ref, nextImpl: callback}); - // $FlowIgnore[incompatible-return] - // $FlowIgnore[incompatible-type] + // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] return function eventFn() { if (isInvalidExecutionContextForEventFunction()) { throw new Error( diff --git a/packages/react-reconciler/src/ReactFiberNewContext.js b/packages/react-reconciler/src/ReactFiberNewContext.js index 02792d863af..81c47d7b649 100644 --- a/packages/react-reconciler/src/ReactFiberNewContext.js +++ b/packages/react-reconciler/src/ReactFiberNewContext.js @@ -551,20 +551,24 @@ function readContextForConsumer( } // This is the first dependency for this component. Create a new list. + // $FlowFixMe[incompatible-type] lastContextDependency = contextItem; consumer.dependencies = __DEV__ - ? { + ? // $FlowFixMe[incompatible-type] + { lanes: NoLanes, firstContext: contextItem, _debugThenableState: null, } - : { + : // $FlowFixMe[incompatible-type] + { lanes: NoLanes, firstContext: contextItem, }; consumer.flags |= NeedsPropagation; } else { // Append a new context item. + // $FlowFixMe[incompatible-type] lastContextDependency = lastContextDependency.next = contextItem; } return value; diff --git a/packages/react-reconciler/src/ReactFiberPerformanceTrack.js b/packages/react-reconciler/src/ReactFiberPerformanceTrack.js index f926bd6085b..416badc9a1e 100644 --- a/packages/react-reconciler/src/ReactFiberPerformanceTrack.js +++ b/packages/react-reconciler/src/ReactFiberPerformanceTrack.js @@ -508,9 +508,11 @@ function logComponentEffectErrored( if (debugTask) { debugTask.run( // $FlowFixMe[method-unbinding] + // $FlowFixMe[incompatible-type] performance.measure.bind(performance, measureName, options), ); } else { + // $FlowFixMe[incompatible-type] performance.measure(measureName, options); } performance.clearMeasures(measureName); @@ -780,9 +782,11 @@ export function logBlockingStart( if (debugTask) { debugTask.run( // $FlowFixMe[method-unbinding] + // $FlowFixMe[incompatible-type] performance.measure.bind(performance, label, measureOptions), ); } else { + // $FlowFixMe[incompatible-type] performance.measure(label, measureOptions); } performance.clearMeasures(label); @@ -886,9 +890,11 @@ export function logGestureStart( if (debugTask) { debugTask.run( // $FlowFixMe[method-unbinding] + // $FlowFixMe[incompatible-type] performance.measure.bind(performance, label, measureOptions), ); } else { + // $FlowFixMe[incompatible-type] performance.measure(label, measureOptions); } performance.clearMeasures(label); @@ -1027,9 +1033,11 @@ export function logTransitionStart( if (debugTask) { debugTask.run( // $FlowFixMe[method-unbinding] + // $FlowFixMe[incompatible-type] performance.measure.bind(performance, label, measureOptions), ); } else { + // $FlowFixMe[incompatible-type] performance.measure(label, measureOptions); } performance.clearMeasures(label); diff --git a/packages/react-reconciler/src/ReactFiberThenable.js b/packages/react-reconciler/src/ReactFiberThenable.js index 643be63ffa1..84c6a93ceca 100644 --- a/packages/react-reconciler/src/ReactFiberThenable.js +++ b/packages/react-reconciler/src/ReactFiberThenable.js @@ -290,6 +290,7 @@ export function suspendCommit(): void { // This extra indirection only exists so it can handle passing // noopSuspenseyCommitThenable through to throwException. // TODO: Factor the thenable check out of throwException + // $FlowFixMe[incompatible-type] suspendedThenable = noopSuspenseyCommitThenable; throw SuspenseyCommitException; } diff --git a/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js b/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js index 9799acc3a07..69967b1ff4f 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js +++ b/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js @@ -726,7 +726,7 @@ async function transformModuleIfNeeded( if (sourceMappingURL) { const sourceMapResult = await loader( sourceMappingURL, - // $FlowFixMe + // $FlowFixMe[incompatible-type] { format: 'json', conditions: [], @@ -738,7 +738,8 @@ async function transformModuleIfNeeded( const sourceMapString = typeof sourceMapResult.source === 'string' ? sourceMapResult.source - : // $FlowFixMe + : // $FlowFixMe[incompatible-call] + // $FlowFixMe[extra-arg] sourceMapResult.source.toString('utf8'); sourceMap = JSON.parse(sourceMapString); diff --git a/packages/react-server-dom-webpack/src/ReactFlightWebpackReferences.js b/packages/react-server-dom-webpack/src/ReactFlightWebpackReferences.js index c0f267ece10..2e8c25bb1b0 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightWebpackReferences.js +++ b/packages/react-server-dom-webpack/src/ReactFlightWebpackReferences.js @@ -255,6 +255,8 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe { const clientReference: ClientReference = registerClientReferenceImpl(({}: any), target.$$id, true); + // $FlowFixMe[incompatible-type] + // $FlowFixMe[incompatible-variance] const proxy = new Proxy(clientReference, proxyHandlers); // Treat this as a resolved Promise for React's use() @@ -302,6 +304,7 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe { target.$$async, ); Object.defineProperty((reference: any), 'name', {value: name}); + // $FlowFixMe[incompatible-type] cachedReference = target[name] = new Proxy(reference, deepProxyHandlers); } return cachedReference; @@ -349,5 +352,8 @@ export function createClientModuleProxy( moduleId, false, ); + // $FlowFixMe[incompatible-type] + // $FlowFixMe[incompatible-variance] + // $FlowFixMe[incompatible-exact] return new Proxy(clientReference, proxyHandlers); } diff --git a/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerNode.js b/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerNode.js index ebddfd10804..a401db3fede 100644 --- a/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerNode.js +++ b/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerNode.js @@ -129,11 +129,12 @@ function startReadingFromDebugChannelReadable( const ws: WebSocket = (stream: any); ws.binaryType = 'arraybuffer'; ws.addEventListener('message', event => { - // $FlowFixMe + // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] onData(event.data); }); ws.addEventListener('error', event => { - // $FlowFixMe + // $FlowFixMe[prop-missing] onError(event.error); }); ws.addEventListener('close', onClose); @@ -673,7 +674,8 @@ function decodeReplyFromAsyncIterable( reportGlobalError(response, reason); if (typeof (iterator: any).throw === 'function') { // The iterator protocol doesn't necessarily include this but a generator do. - // $FlowFixMe should be able to pass mixed + // $FlowFixMe[incompatible-call] should be able to pass mixed + // $FlowFixMe[prop-missing] iterator.throw(reason).then(error, error); } } diff --git a/packages/react-server/src/ReactFizzHooks.js b/packages/react-server/src/ReactFizzHooks.js index 0ac1859249d..9dfd5c3c2b7 100644 --- a/packages/react-server/src/ReactFizzHooks.js +++ b/packages/react-server/src/ReactFizzHooks.js @@ -546,8 +546,8 @@ function throwOnUseEffectEventCall() { export function useEffectEvent) => Return>( callback: F, ): F { - // $FlowIgnore[incompatible-return] - // $FlowIgnore[incompatible-type] + // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] return throwOnUseEffectEventCall; } @@ -631,7 +631,7 @@ function useActionState( const actionStateHookIndex = actionStateCounter++; const request: Request = (currentlyRenderingRequest: any); - // $FlowIgnore[prop-missing] + // $FlowFixMe[prop-missing] const formAction = action.$$FORM_ACTION; if (typeof formAction === 'function') { // This is a server action. These have additional features to enable @@ -653,7 +653,7 @@ function useActionState( let state = initialState; const componentKeyPath = (currentlyRenderingKeyPath: any); const postbackActionState = getFormState(request); - // $FlowIgnore[prop-missing] + // $FlowFixMe[prop-missing] const isSignatureEqual = action.$$IS_SIGNATURE_EQUAL; if ( postbackActionState !== null && @@ -687,9 +687,9 @@ function useActionState( boundAction(payload); }; - // $FlowIgnore[prop-missing] + // $FlowFixMe[prop-missing] if (typeof boundAction.$$FORM_ACTION === 'function') { - // $FlowIgnore[prop-missing] + // $FlowFixMe[prop-missing] dispatch.$$FORM_ACTION = (prefix: string) => { const metadata: ReactCustomFormAction = boundAction.$$FORM_ACTION(prefix); diff --git a/packages/react-server/src/ReactFizzServer.js b/packages/react-server/src/ReactFizzServer.js index 4ad48d79fba..a99d245bb0c 100644 --- a/packages/react-server/src/ReactFizzServer.js +++ b/packages/react-server/src/ReactFizzServer.js @@ -1273,7 +1273,7 @@ function renderSuspenseBoundary( } return; } - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. const task: RenderTask = someTask; const prevKeyPath = task.keyPath; @@ -2089,7 +2089,8 @@ function renderSuspenseList( // If it's an iterator we need to continue reading where we left // off. We can do that by reading the first few rows from the previous // thenable state. - // $FlowFixMe + // $FlowFixMe[incompatible-type] + // $FlowFixMe[underconstrained-implicit-instantiation] let step = readPreviousThenableFromState(); while (step !== undefined) { if (step.done) { @@ -2226,7 +2227,7 @@ function renderHostElement( props, )); if (isPreambleContext(newContext)) { - // $FlowFixMe: Refined + // $FlowFixMe[incompatible-type]: Refined renderPreamble(request, (task: RenderTask), segment, children); } else { // We use the non-destructive form because if something suspends, we still @@ -3414,7 +3415,8 @@ function retryNode(request: Request, task: Task): void { // If it's an iterator we need to continue reading where we left // off. We can do that by reading the first few rows from the previous // thenable state. - // $FlowFixMe + // $FlowFixMe[incompatible-type] + // $FlowFixMe[underconstrained-implicit-instantiation] let step = readPreviousThenableFromState(); while (step !== undefined) { if (step.done) { @@ -3704,7 +3706,7 @@ function renderChildrenArray( if (task.replay !== null) { replayFragment( request, - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. task, children, childIndex, @@ -4097,7 +4099,7 @@ function renderNode( : null; const newTask = spawnNewSuspendedReplayTask( request, - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. task, thenableState, ); @@ -4133,7 +4135,7 @@ function renderNode( : null; const newTask = spawnNewSuspendedReplayTask( request, - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. task, thenableState, ); @@ -4198,7 +4200,7 @@ function renderNode( : null; const newTask = spawnNewSuspendedRenderTask( request, - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. task, thenableState, ); @@ -4233,7 +4235,7 @@ function renderNode( : null; const newTask = spawnNewSuspendedRenderTask( request, - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. task, thenableState, ); @@ -4944,13 +4946,13 @@ function retryTask(request: Request, task: Task): void { if (segment === null) { retryReplayTask( request, - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. task, ); } else { retryRenderTask( request, - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. task, segment, ); diff --git a/packages/react-server/src/ReactFlightActionServer.js b/packages/react-server/src/ReactFlightActionServer.js index c591f27499f..a1391083427 100644 --- a/packages/react-server/src/ReactFlightActionServer.js +++ b/packages/react-server/src/ReactFlightActionServer.js @@ -71,10 +71,12 @@ function decodeBoundActionMetaData( bound: null | Promise>, }>(actionResponse); // Force it to initialize - // $FlowFixMe + // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] refPromise.then(() => {}); if (refPromise.status !== 'fulfilled') { - // $FlowFixMe + // $FlowFixMe[incompatible-use] + // $FlowFixMe[prop-missing] throw refPromise.reason; } return refPromise.value; diff --git a/packages/react-server/src/ReactFlightServer.js b/packages/react-server/src/ReactFlightServer.js index e0e4948348b..8559473d99e 100644 --- a/packages/react-server/src/ReactFlightServer.js +++ b/packages/react-server/src/ReactFlightServer.js @@ -1144,7 +1144,7 @@ function serializeReadableStream( // receiving side. It also implies that different chunks can be split up or merged as opposed // to a readable stream that happens to have Uint8Array as the type which might expect it to be // received in the same slices. - // $FlowFixMe: This is a Node.js extension. + // $FlowFixMe[prop-missing]: This is a Node.js extension. let supportsBYOB: void | boolean = stream.supportsBYOB; if (supportsBYOB === undefined) { try { @@ -1222,7 +1222,6 @@ function serializeReadableStream( erroredTask(request, streamTask, reason); enqueueFlush(request); - // $FlowFixMe should be able to pass mixed reader.cancel(reason).then(error, error); } function abortStream() { @@ -1241,7 +1240,6 @@ function serializeReadableStream( erroredTask(request, streamTask, reason); enqueueFlush(request); } - // $FlowFixMe should be able to pass mixed reader.cancel(reason).then(error, error); } @@ -1355,7 +1353,8 @@ function serializeAsyncIterable( enqueueFlush(request); if (typeof (iterator: any).throw === 'function') { // The iterator protocol doesn't necessarily include this but a generator do. - // $FlowFixMe should be able to pass mixed + // $FlowFixMe[incompatible-call] should be able to pass mixed + // $FlowFixMe[prop-missing] iterator.throw(reason).then(error, error); } } @@ -1377,7 +1376,8 @@ function serializeAsyncIterable( } if (typeof (iterator: any).throw === 'function') { // The iterator protocol doesn't necessarily include this but a generator do. - // $FlowFixMe should be able to pass mixed + // $FlowFixMe[incompatible-call] should be able to pass mixed + // $FlowFixMe[prop-missing] iterator.throw(reason).then(error, error); } } @@ -1577,10 +1577,10 @@ function processServerComponentReturnValue( // tempting to try to return the value from a generator. if (iterator === iterableChild) { const isGeneratorComponent = - // $FlowIgnore[method-unbinding] + // $FlowFixMe[method-unbinding] Object.prototype.toString.call(Component) === '[object GeneratorFunction]' && - // $FlowIgnore[method-unbinding] + // $FlowFixMe[method-unbinding] Object.prototype.toString.call(iterableChild) === '[object Generator]'; if (!isGeneratorComponent) { @@ -1617,10 +1617,10 @@ function processServerComponentReturnValue( // tempting to try to return the value from a generator. if (iterator === iterableChild) { const isGeneratorComponent = - // $FlowIgnore[method-unbinding] + // $FlowFixMe[method-unbinding] Object.prototype.toString.call(Component) === '[object AsyncGeneratorFunction]' && - // $FlowIgnore[method-unbinding] + // $FlowFixMe[method-unbinding] Object.prototype.toString.call(iterableChild) === '[object AsyncGenerator]'; if (!isGeneratorComponent) { @@ -3231,7 +3231,6 @@ function serializeDebugBlob(request: Request, blob: Blob): string { const digest = ''; emitErrorChunk(request, id, digest, reason, true, null); enqueueFlush(request); - // $FlowFixMe should be able to pass mixed reader.cancel(reason).then(noop, noop); } // $FlowFixMe[incompatible-call] @@ -3284,7 +3283,6 @@ function serializeBlob(request: Request, blob: Blob): string { request.cacheController.signal.removeEventListener('abort', abortBlob); erroredTask(request, newTask, reason); enqueueFlush(request); - // $FlowFixMe should be able to pass mixed reader.cancel(reason).then(error, error); } function abortBlob() { @@ -3303,7 +3301,6 @@ function serializeBlob(request: Request, blob: Blob): string { erroredTask(request, newTask, reason); enqueueFlush(request); } - // $FlowFixMe should be able to pass mixed reader.cancel(reason).then(error, error); } diff --git a/packages/react-server/src/ReactFlightServerConfigDebugNode.js b/packages/react-server/src/ReactFlightServerConfigDebugNode.js index 9bb521be406..afd397b041e 100644 --- a/packages/react-server/src/ReactFlightServerConfigDebugNode.js +++ b/packages/react-server/src/ReactFlightServerConfigDebugNode.js @@ -237,7 +237,7 @@ export function initAsyncDebugInfo(): void { // If we begin before we resolve, that means that this is actually already resolved but // the promiseResolve hook is called at the end of the execution. So we track the time // in the before call instead. - // $FlowFixMe + // $FlowFixMe[incompatible-type] lastRanAwait = resolvePromiseOrAwaitNode(node, performance.now()); break; } diff --git a/packages/react-server/src/ReactServerConsoleConfigBrowser.js b/packages/react-server/src/ReactServerConsoleConfigBrowser.js index be8bf953467..19e03a14756 100644 --- a/packages/react-server/src/ReactServerConsoleConfigBrowser.js +++ b/packages/react-server/src/ReactServerConsoleConfigBrowser.js @@ -36,7 +36,7 @@ export function unbadgeConsole( case 'table': { // These methods cannot be colorized because they don't take a formatting string. // So we wouldn't have added any badge in the first place. - // $FlowFixMe + // $FlowFixMe[incompatible-type] return null; } case 'assert': { diff --git a/packages/react-server/src/ReactServerConsoleConfigPlain.js b/packages/react-server/src/ReactServerConsoleConfigPlain.js index d93e5f1a0dd..0208af4c975 100644 --- a/packages/react-server/src/ReactServerConsoleConfigPlain.js +++ b/packages/react-server/src/ReactServerConsoleConfigPlain.js @@ -27,7 +27,7 @@ export function unbadgeConsole( case 'table': { // These methods cannot be colorized because they don't take a formatting string. // So we wouldn't have added any badge in the first place. - // $FlowFixMe + // $FlowFixMe[incompatible-type] return null; } case 'assert': { diff --git a/packages/react-server/src/ReactServerConsoleConfigServer.js b/packages/react-server/src/ReactServerConsoleConfigServer.js index 7987b9b262f..bee6d7ad397 100644 --- a/packages/react-server/src/ReactServerConsoleConfigServer.js +++ b/packages/react-server/src/ReactServerConsoleConfigServer.js @@ -35,7 +35,7 @@ export function unbadgeConsole( case 'table': { // These methods cannot be colorized because they don't take a formatting string. // So we wouldn't have added any badge in the first place. - // $FlowFixMe + // $FlowFixMe[incompatible-type] return null; } case 'assert': { diff --git a/packages/react-server/src/ReactSharedInternalsServer.js b/packages/react-server/src/ReactSharedInternalsServer.js index efc3588a645..2dbb64c8d46 100644 --- a/packages/react-server/src/ReactSharedInternalsServer.js +++ b/packages/react-server/src/ReactSharedInternalsServer.js @@ -12,7 +12,9 @@ import type {SharedStateServer} from 'react/src/ReactSharedInternalsServer'; import * as React from 'react'; const ReactSharedInternalsServer: SharedStateServer = - // $FlowFixMe: It's defined in the one we resolve to. + // $FlowFixMe[prop-missing]: It's defined in the one we resolve to. + // $FlowFixMe[incompatible-type] + // $FlowFixMe[missing-export] React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; if (!ReactSharedInternalsServer) { diff --git a/packages/react/src/ReactChildren.js b/packages/react/src/ReactChildren.js index d4c41d6669a..3969d410d65 100644 --- a/packages/react/src/ReactChildren.js +++ b/packages/react/src/ReactChildren.js @@ -369,7 +369,7 @@ function mapChildren( context: mixed, ): ?Array { if (children == null) { - // $FlowFixMe limitation refining abstract types in Flow + // $FlowFixMe[incompatible-type] limitation refining abstract types in Flow return children; } const result: Array = []; diff --git a/packages/react/src/ReactLazy.js b/packages/react/src/ReactLazy.js index 47f37afbae2..bf2a1262f84 100644 --- a/packages/react/src/ReactLazy.js +++ b/packages/react/src/ReactLazy.js @@ -112,9 +112,11 @@ function lazyInitializer(payload: Payload): T { const debugValue = moduleObject == null ? undefined : moduleObject.default; resolveDebugValue(debugValue); - // $FlowFixMe + // $FlowFixMe[incompatible-use] + // $FlowFixMe[prop-missing] ioInfo.value.status = 'fulfilled'; - // $FlowFixMe + // $FlowFixMe[incompatible-use] + // $FlowFixMe[prop-missing] ioInfo.value.value = debugValue; } // Make the thenable introspectable @@ -143,12 +145,15 @@ function lazyInitializer(payload: Payload): T { // $FlowFixMe[cannot-write] ioInfo.end = performance.now(); // Hide unhandled rejections. - // $FlowFixMe + // $FlowFixMe[incompatible-use] + // $FlowFixMe[prop-missing] ioInfo.value.then(noop, noop); rejectDebugValue(error); - // $FlowFixMe + // $FlowFixMe[incompatible-use] + // $FlowFixMe[prop-missing] ioInfo.value.status = 'rejected'; - // $FlowFixMe + // $FlowFixMe[incompatible-use] + // $FlowFixMe[prop-missing] ioInfo.value.reason = error; } // Make the thenable introspectable diff --git a/yarn.lock b/yarn.lock index 38d280c8b84..4fb4cb244c6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9222,12 +9222,12 @@ flatted@^3.2.9: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.1.tgz#21db470729a6734d4997002f439cb308987f567a" integrity sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw== -flow-bin@^0.280.0: - version "0.280.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.280.0.tgz#73db532b4ea072a20a47277a38c0ab9f4f4600e6" - integrity sha512-7WHDjleRd6KDggSYovdrNSz1xMM9HKSI3ajHF3xMmWaETxx3SHnl60cclW6mPm3z+0FUVQSr7XFLiGSW3Zkq7Q== +flow-bin@^0.281.0: + version "0.281.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.281.0.tgz#be49afd6da986ba355e27d38775547b60b398e65" + integrity sha512-jgSKNLolqwtI4CZ/lTh/YKf0JAtFGTrf/8ETZkfxxyT5AYB9NfiO5KQttW0gtd63plppvw3ghyVFKLSK3TH6hg== -flow-remove-types@^2.280.0: +flow-remove-types@^2.281.0: version "2.293.0" resolved "https://registry.yarnpkg.com/flow-remove-types/-/flow-remove-types-2.293.0.tgz#ff63c979bbf0da625cc5a9a33af546261ee23307" integrity sha512-UoF3jXBZ3YH1SYSMq+bLchQ7HGOBykPHThCyl7FdWspCzcW1qQ2nVbkbv5fclzLOzlEZ42c8LpeliAC0tqORzA== From 5694f9a99ce3836d0f3b2cbe3297633e99a456d6 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Mon, 8 Dec 2025 13:07:07 -0800 Subject: [PATCH 3/4] [flow] Upgrade from 0.281 -> 0.282 Add suppression for React\$Element incompatibility with ReactNodeList in ReactDOMRootFB.js render function. Flow 0.282 has stricter type checking for the React\$Node union type. --- package.json | 4 ++-- packages/react-dom/src/client/ReactDOMRootFB.js | 1 + yarn.lock | 10 +++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index af3b4b1e624..a6296bc8259 100644 --- a/package.json +++ b/package.json @@ -75,8 +75,8 @@ "eslint-plugin-react-internal": "link:./scripts/eslint-rules", "fbjs-scripts": "^3.0.1", "filesize": "^6.0.1", - "flow-bin": "^0.281.0", - "flow-remove-types": "^2.281.0", + "flow-bin": "^0.282.0", + "flow-remove-types": "^2.282.0", "flow-typed": "^4.1.1", "glob": "^7.1.6", "glob-stream": "^6.1.0", diff --git a/packages/react-dom/src/client/ReactDOMRootFB.js b/packages/react-dom/src/client/ReactDOMRootFB.js index 8a677a5b82f..6520285b0fd 100644 --- a/packages/react-dom/src/client/ReactDOMRootFB.js +++ b/packages/react-dom/src/client/ReactDOMRootFB.js @@ -427,6 +427,7 @@ export function render( } return legacyRenderSubtreeIntoContainer( null, + // $FlowFixMe[incompatible-type] React$Element is a subtype of ReactNodeList element, container, false, diff --git a/yarn.lock b/yarn.lock index 4fb4cb244c6..5bffcc53432 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9222,12 +9222,12 @@ flatted@^3.2.9: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.1.tgz#21db470729a6734d4997002f439cb308987f567a" integrity sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw== -flow-bin@^0.281.0: - version "0.281.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.281.0.tgz#be49afd6da986ba355e27d38775547b60b398e65" - integrity sha512-jgSKNLolqwtI4CZ/lTh/YKf0JAtFGTrf/8ETZkfxxyT5AYB9NfiO5KQttW0gtd63plppvw3ghyVFKLSK3TH6hg== +flow-bin@^0.282.0: + version "0.282.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.282.0.tgz#ecbbd0c032c37eb7791eb66a790b9902eab492a6" + integrity sha512-gZnUBsnMN8iYAcvJLEoF04gLaegv93h8IB1e4HURBaPuyUZoBaStAm5z24wl9NviaB66GbN+hZ9vxDSa+HzlzQ== -flow-remove-types@^2.281.0: +flow-remove-types@^2.282.0: version "2.293.0" resolved "https://registry.yarnpkg.com/flow-remove-types/-/flow-remove-types-2.293.0.tgz#ff63c979bbf0da625cc5a9a33af546261ee23307" integrity sha512-UoF3jXBZ3YH1SYSMq+bLchQ7HGOBykPHThCyl7FdWspCzcW1qQ2nVbkbv5fclzLOzlEZ42c8LpeliAC0tqORzA== From bb9c93e47971ba079d525212fb17cfe9a1cceb01 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Mon, 8 Dec 2025 13:07:07 -0800 Subject: [PATCH 4/4] [flow] Upgrade from 0.282 -> 0.286 Flow 0.286 introduced stricter constant-condition detection that flags build-time feature flags (supportsMutation, supportsHydration, isPrimaryRenderer, enableProfiling, etc.) and narrowed null checks. Added inline $FlowFixMe suppressions to preserve existing runtime behavior. --- package.json | 4 +-- packages/react-cache/src/LRU.js | 1 + .../react-client/src/ReactFlightClient.js | 1 + .../src/ReactFlightReplyClient.js | 2 ++ .../forks/ReactFlightClientConfig.custom.js | 2 +- ...ReactFlightClientConfig.dom-browser-esm.js | 2 +- ...ctFlightClientConfig.dom-browser-parcel.js | 2 +- ...lightClientConfig.dom-browser-turbopack.js | 2 +- .../ReactFlightClientConfig.dom-browser.js | 2 +- .../forks/ReactFlightClientConfig.dom-bun.js | 2 +- ...ReactFlightClientConfig.dom-edge-parcel.js | 2 +- ...ctFlightClientConfig.dom-edge-turbopack.js | 2 +- ...eactFlightClientConfig.dom-edge-webpack.js | 2 +- .../ReactFlightClientConfig.dom-legacy.js | 2 +- .../ReactFlightClientConfig.dom-node-esm.js | 2 +- ...ReactFlightClientConfig.dom-node-parcel.js | 2 +- ...ctFlightClientConfig.dom-node-turbopack.js | 2 +- ...ctFlightClientConfig.dom-node-unbundled.js | 2 +- .../forks/ReactFlightClientConfig.dom-node.js | 2 +- .../forks/ReactFlightClientConfig.markup.js | 2 +- .../react-debug-tools/src/ReactDebugHooks.js | 3 ++ .../src/client/ReactDOMComponent.js | 6 ++++ .../src/client/ReactDOMInput.js | 1 + .../src/client/ReactDOMTextarea.js | 2 ++ .../src/client/ReactFiberConfigDOM.js | 10 ++++-- .../src/client/validateDOMNesting.js | 1 + .../src/events/DOMPluginEventSystem.js | 3 ++ .../src/events/ReactDOMEventReplaying.js | 2 ++ .../src/server/ReactFizzConfigDOM.js | 7 +++++ packages/react-dom/src/client/ReactDOMRoot.js | 5 +++ .../react-dom/src/shared/ReactDOMFloat.js | 1 + .../src/ReactCapturedValue.js | 1 + .../react-reconciler/src/ReactChildFiber.js | 4 +++ packages/react-reconciler/src/ReactFiber.js | 23 ++++++++++++++ .../react-reconciler/src/ReactFiberAct.js | 1 + .../src/ReactFiberApplyGesture.js | 6 ++++ .../src/ReactFiberBeginWork.js | 19 ++++++++++++ .../src/ReactFiberClassComponent.js | 2 ++ .../src/ReactFiberClassUpdateQueue.js | 2 ++ .../src/ReactFiberCommitEffects.js | 1 + .../src/ReactFiberCommitHostEffects.js | 1 + .../src/ReactFiberCommitViewTransitions.js | 3 ++ .../src/ReactFiberCommitWork.js | 31 +++++++++++++++++++ .../src/ReactFiberCompleteWork.js | 15 +++++++++ .../src/ReactFiberConcurrentUpdates.js | 1 + .../src/ReactFiberConfigWithNoResources.js | 2 +- .../src/ReactFiberConfigWithNoSingletons.js | 2 +- .../react-reconciler/src/ReactFiberHooks.js | 5 +++ .../src/ReactFiberHostContext.js | 2 ++ .../src/ReactFiberHydrationContext.js | 10 ++++++ .../react-reconciler/src/ReactFiberLane.js | 1 + .../src/ReactFiberNewContext.js | 5 +++ .../src/ReactFiberRootScheduler.js | 1 + .../react-reconciler/src/ReactFiberScope.js | 2 ++ .../src/ReactFiberSuspenseComponent.js | 1 + .../src/ReactFiberSuspenseContext.js | 1 + .../src/ReactFiberTracingMarkerComponent.js | 3 ++ .../src/ReactFiberTransition.js | 4 +++ .../src/ReactFiberWorkLoop.js | 2 ++ .../src/ReactTestSelectors.js | 6 ++++ .../src/ReactFizzComponentStack.js | 1 + packages/react-server/src/ReactFizzHooks.js | 5 +++ .../react-server/src/ReactFizzNewContext.js | 5 +++ packages/react-server/src/ReactFizzServer.js | 30 ++++++++++++++++++ .../src/ReactFizzViewTransitionComponent.js | 2 ++ packages/react-server/src/ReactFlightHooks.js | 1 + .../react-server/src/ReactFlightServer.js | 12 +++++++ packages/react/src/ReactAct.js | 1 + packages/react/src/ReactCacheImpl.js | 1 + packages/react/src/ReactStartTransition.js | 9 +++++- packages/react/src/ReactTaint.js | 8 ++++- packages/scheduler/src/SchedulerProfiling.js | 8 +++++ packages/scheduler/src/forks/Scheduler.js | 14 +++++++++ packages/scheduler/src/forks/SchedulerMock.js | 13 ++++++++ .../scheduler/src/forks/SchedulerPostTask.js | 1 + yarn.lock | 10 +++--- 76 files changed, 330 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index a6296bc8259..b9cc3528f0b 100644 --- a/package.json +++ b/package.json @@ -75,8 +75,8 @@ "eslint-plugin-react-internal": "link:./scripts/eslint-rules", "fbjs-scripts": "^3.0.1", "filesize": "^6.0.1", - "flow-bin": "^0.282.0", - "flow-remove-types": "^2.282.0", + "flow-bin": "^0.286.0", + "flow-remove-types": "^2.286.0", "flow-typed": "^4.1.1", "glob": "^7.1.6", "glob-stream": "^6.1.0", diff --git a/packages/react-cache/src/LRU.js b/packages/react-cache/src/LRU.js index bf4e4d4c6de..7526ce7eb5e 100644 --- a/packages/react-cache/src/LRU.js +++ b/packages/react-cache/src/LRU.js @@ -115,6 +115,7 @@ export function createLRU(limit: number): LRU { function access(entry: Entry): T { const next = entry.next; + // $FlowFixMe[invalid-compare] Entry.next can be null at runtime if (next !== null) { // Entry already cached const resolvedFirst: Entry = (first: any); diff --git a/packages/react-client/src/ReactFlightClient.js b/packages/react-client/src/ReactFlightClient.js index 4beb9fe6617..64a41f8d128 100644 --- a/packages/react-client/src/ReactFlightClient.js +++ b/packages/react-client/src/ReactFlightClient.js @@ -501,6 +501,7 @@ function filterDebugInfo( response: Response, value: {_debugInfo: ReactDebugInfo, ...}, ) { + // $FlowFixMe[invalid-compare] if (response._debugEndTime === null) { // No end time was defined, so we keep all debug info entries. return; diff --git a/packages/react-client/src/ReactFlightReplyClient.js b/packages/react-client/src/ReactFlightReplyClient.js index 0b0e71b6a3a..d2ea1e6b110 100644 --- a/packages/react-client/src/ReactFlightReplyClient.js +++ b/packages/react-client/src/ReactFlightReplyClient.js @@ -647,6 +647,7 @@ export function processReply( const iteratorFn = getIteratorFn(value); if (iteratorFn) { const iterator = iteratorFn.call(value); + // $FlowFixMe[invalid-compare] if (iterator === value) { // Iterator, not Iterable const iteratorId = nextPartId++; @@ -969,6 +970,7 @@ function customEncodeFormAction( ); } let boundPromise: Promise> = (referenceClosure.bound: any); + // $FlowFixMe[invalid-compare] if (boundPromise === null) { boundPromise = Promise.resolve([]); } diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.custom.js b/packages/react-client/src/forks/ReactFlightClientConfig.custom.js index a6c0c933d2a..65de2208b78 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.custom.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.custom.js @@ -39,7 +39,7 @@ export const getModuleDebugInfo = $$$config.getModuleDebugInfo; export const dispatchHint = $$$config.dispatchHint; export const prepareDestinationForModule = $$$config.prepareDestinationForModule; -export const usedWithSSR = true; +export const usedWithSSR: boolean = true; export opaque type Source = mixed; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser-esm.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser-esm.js index dbc89a2677d..8ac6b08c6d5 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser-esm.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser-esm.js @@ -15,4 +15,4 @@ export * from 'react-client/src/ReactClientConsoleConfigBrowser'; export * from 'react-server-dom-esm/src/client/ReactFlightClientConfigBundlerESM'; export * from 'react-server-dom-esm/src/client/ReactFlightClientConfigTargetESMBrowser'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; -export const usedWithSSR = false; +export const usedWithSSR: boolean = false; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser-parcel.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser-parcel.js index 89b834784f0..b5bab2a4c42 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser-parcel.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser-parcel.js @@ -15,4 +15,4 @@ export * from 'react-client/src/ReactClientConsoleConfigBrowser'; export * from 'react-server-dom-parcel/src/client/ReactFlightClientConfigBundlerParcel'; export * from 'react-server-dom-parcel/src/client/ReactFlightClientConfigTargetParcelBrowser'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; -export const usedWithSSR = false; +export const usedWithSSR: boolean = false; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser-turbopack.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser-turbopack.js index 6a071981be9..110ec0a71af 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser-turbopack.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser-turbopack.js @@ -16,4 +16,4 @@ export * from 'react-server-dom-turbopack/src/client/ReactFlightClientConfigBund export * from 'react-server-dom-turbopack/src/client/ReactFlightClientConfigBundlerTurbopackBrowser'; export * from 'react-server-dom-turbopack/src/client/ReactFlightClientConfigTargetTurbopackBrowser'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; -export const usedWithSSR = false; +export const usedWithSSR: boolean = false; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser.js index 73d27adefa8..f89e6f06976 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser.js @@ -16,4 +16,4 @@ export * from 'react-server-dom-webpack/src/client/ReactFlightClientConfigBundle export * from 'react-server-dom-webpack/src/client/ReactFlightClientConfigBundlerWebpackBrowser'; export * from 'react-server-dom-webpack/src/client/ReactFlightClientConfigTargetWebpackBrowser'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; -export const usedWithSSR = false; +export const usedWithSSR: boolean = false; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-bun.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-bun.js index 24caf0df88f..c47c971858f 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-bun.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-bun.js @@ -26,4 +26,4 @@ export const preloadModule: any = null; export const requireModule: any = null; export const getModuleDebugInfo: any = null; export const prepareDestinationForModule: any = null; -export const usedWithSSR = true; +export const usedWithSSR: boolean = true; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-parcel.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-parcel.js index 626f26903ed..1b4334ae09a 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-parcel.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-parcel.js @@ -15,4 +15,4 @@ export * from 'react-client/src/ReactClientConsoleConfigServer'; export * from 'react-server-dom-parcel/src/client/ReactFlightClientConfigBundlerParcel'; export * from 'react-server-dom-parcel/src/client/ReactFlightClientConfigTargetParcelServer'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; -export const usedWithSSR = true; +export const usedWithSSR: boolean = true; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-turbopack.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-turbopack.js index fbdb9fc683a..e5e3dd0f9b2 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-turbopack.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-turbopack.js @@ -16,4 +16,4 @@ export * from 'react-server-dom-turbopack/src/client/ReactFlightClientConfigBund export * from 'react-server-dom-turbopack/src/client/ReactFlightClientConfigBundlerTurbopackServer'; export * from 'react-server-dom-turbopack/src/client/ReactFlightClientConfigTargetTurbopackServer'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; -export const usedWithSSR = true; +export const usedWithSSR: boolean = true; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-webpack.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-webpack.js index f328a3e2ed7..8160fe4c1c8 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-webpack.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-webpack.js @@ -16,4 +16,4 @@ export * from 'react-server-dom-webpack/src/client/ReactFlightClientConfigBundle export * from 'react-server-dom-webpack/src/client/ReactFlightClientConfigBundlerWebpackServer'; export * from 'react-server-dom-webpack/src/client/ReactFlightClientConfigTargetWebpackServer'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; -export const usedWithSSR = true; +export const usedWithSSR: boolean = true; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-legacy.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-legacy.js index 0f7381fc5a3..5edde6f335c 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-legacy.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-legacy.js @@ -27,4 +27,4 @@ export const requireModule: any = null; export const getModuleDebugInfo: any = null; export const dispatchHint: any = null; export const prepareDestinationForModule: any = null; -export const usedWithSSR = true; +export const usedWithSSR: boolean = true; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-esm.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-esm.js index 8cb512ea44a..e15cdf2921a 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-esm.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-esm.js @@ -15,4 +15,4 @@ export * from 'react-client/src/ReactClientConsoleConfigServer'; export * from 'react-server-dom-esm/src/client/ReactFlightClientConfigBundlerESM'; export * from 'react-server-dom-esm/src/client/ReactFlightClientConfigTargetESMServer'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; -export const usedWithSSR = true; +export const usedWithSSR: boolean = true; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-parcel.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-parcel.js index 466d21164cc..373703d6fcb 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-parcel.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-parcel.js @@ -15,4 +15,4 @@ export * from 'react-client/src/ReactClientConsoleConfigServer'; export * from 'react-server-dom-parcel/src/client/ReactFlightClientConfigBundlerParcel'; export * from 'react-server-dom-parcel/src/client/ReactFlightClientConfigTargetParcelServer'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; -export const usedWithSSR = true; +export const usedWithSSR: boolean = true; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-turbopack.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-turbopack.js index ec97d45077b..81f41679ee7 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-turbopack.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-turbopack.js @@ -16,4 +16,4 @@ export * from 'react-server-dom-turbopack/src/client/ReactFlightClientConfigBund export * from 'react-server-dom-turbopack/src/client/ReactFlightClientConfigBundlerTurbopackServer'; export * from 'react-server-dom-turbopack/src/client/ReactFlightClientConfigTargetTurbopackServer'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; -export const usedWithSSR = true; +export const usedWithSSR: boolean = true; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-unbundled.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-unbundled.js index c95a3ba07f5..7b9ecb20f10 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-unbundled.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-unbundled.js @@ -15,4 +15,4 @@ export * from 'react-client/src/ReactClientConsoleConfigServer'; export * from 'react-server-dom-unbundled/src/client/ReactFlightClientConfigBundlerNode'; export * from 'react-server-dom-unbundled/src/client/ReactFlightClientConfigTargetNodeServer'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; -export const usedWithSSR = true; +export const usedWithSSR: boolean = true; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-node.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-node.js index 9840d5bc911..1fa4a6c33e3 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-node.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-node.js @@ -15,4 +15,4 @@ export * from 'react-server-dom-webpack/src/client/ReactFlightClientConfigBundle export * from 'react-server-dom-webpack/src/client/ReactFlightClientConfigBundlerWebpackServer'; export * from 'react-server-dom-webpack/src/client/ReactFlightClientConfigTargetWebpackServer'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; -export const usedWithSSR = true; +export const usedWithSSR: boolean = true; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.markup.js b/packages/react-client/src/forks/ReactFlightClientConfig.markup.js index fcd67245044..94ded11b4bb 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.markup.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.markup.js @@ -68,7 +68,7 @@ export function getModuleDebugInfo(metadata: ClientReference): null { ); } -export const usedWithSSR = true; +export const usedWithSSR: boolean = true; type HintCode = string; type HintModel = null; // eslint-disable-line no-unused-vars diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js index 89f4609e289..80f36495ec2 100644 --- a/packages/react-debug-tools/src/ReactDebugHooks.js +++ b/packages/react-debug-tools/src/ReactDebugHooks.js @@ -200,6 +200,7 @@ const SuspenseException: mixed = new Error( ); function use(usable: Usable): T { + // $FlowFixMe[invalid-compare] if (usable !== null && typeof usable === 'object') { // $FlowFixMe[method-unbinding] if (typeof usable.then === 'function') { @@ -1341,10 +1342,12 @@ export function inspectHooksOfFiber( } else if (hasOwnProperty.call(currentFiber, 'dependencies_old')) { const dependencies: Dependencies = (currentFiber: any).dependencies_old; currentContextDependency = + // $FlowFixMe[invalid-compare] dependencies !== null ? dependencies.firstContext : null; } else if (hasOwnProperty.call(currentFiber, 'dependencies_new')) { const dependencies: Dependencies = (currentFiber: any).dependencies_new; currentContextDependency = + // $FlowFixMe[invalid-compare] dependencies !== null ? dependencies.firstContext : null; } else if (hasOwnProperty.call(currentFiber, 'contextDependencies')) { const contextDependencies = (currentFiber: any).contextDependencies; diff --git a/packages/react-dom-bindings/src/client/ReactDOMComponent.js b/packages/react-dom-bindings/src/client/ReactDOMComponent.js index 549b279f1da..199f92414cb 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMComponent.js +++ b/packages/react-dom-bindings/src/client/ReactDOMComponent.js @@ -2054,6 +2054,7 @@ function hydrateAttribute( if (__DEV__) { checkAttributeStringCoercion(value, propKey); } + // $FlowFixMe[invalid-compare] if (serverValue === '' + value) { return; } @@ -2118,6 +2119,7 @@ function hydrateOverloadedBooleanAttribute( case 'symbol': return; default: + // $FlowFixMe[invalid-compare] if (value === false) { return; } @@ -2132,6 +2134,7 @@ function hydrateOverloadedBooleanAttribute( case 'symbol': break; case 'boolean': + // $FlowFixMe[invalid-compare] if (value === true && serverValue === '') { return; } @@ -2140,6 +2143,7 @@ function hydrateOverloadedBooleanAttribute( if (__DEV__) { checkAttributeStringCoercion(value, propKey); } + // $FlowFixMe[invalid-compare] if (serverValue === '' + value) { return; } @@ -2231,6 +2235,7 @@ function hydrateNumericAttribute( if (__DEV__) { checkAttributeStringCoercion(value, propKey); } + // $FlowFixMe[invalid-compare] if (serverValue === '' + value) { return; } @@ -2282,6 +2287,7 @@ function hydratePositiveNumericAttribute( if (__DEV__) { checkAttributeStringCoercion(value, propKey); } + // $FlowFixMe[invalid-compare] if (serverValue === '' + value) { return; } diff --git a/packages/react-dom-bindings/src/client/ReactDOMInput.js b/packages/react-dom-bindings/src/client/ReactDOMInput.js index b6e665e1288..0ae9824cb84 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMInput.js +++ b/packages/react-dom-bindings/src/client/ReactDOMInput.js @@ -122,6 +122,7 @@ export function updateInput( if (type === 'number') { if ( // $FlowFixMe[incompatible-type] + // $FlowFixMe[invalid-compare] (value === 0 && node.value === '') || // We explicitly want to coerce to number here if possible. // eslint-disable-next-line diff --git a/packages/react-dom-bindings/src/client/ReactDOMTextarea.js b/packages/react-dom-bindings/src/client/ReactDOMTextarea.js index bc346b4bce4..75fe6b8fabc 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMTextarea.js +++ b/packages/react-dom-bindings/src/client/ReactDOMTextarea.js @@ -138,7 +138,9 @@ export function initTextarea( // initial value. In IE10/IE11 there is a bug where the placeholder attribute // will populate textContent as well. // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/ + // $FlowFixMe[invalid-compare] if (textContent === stringValue) { + // $FlowFixMe[invalid-compare] if (textContent !== '' && textContent !== null) { node.value = textContent; } diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js index f64d0eaebc1..ebbf7fe7d19 100644 --- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js +++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js @@ -1040,7 +1040,9 @@ export function appendChildToContainer( // defined. // https://github.com/facebook/react/issues/11918 const reactRootContainer = container._reactRootContainer; + // $FlowFixMe[invalid-compare] if ( + // $FlowFixMe[invalid-compare] (reactRootContainer === null || reactRootContainer === undefined) && parentNode.onclick === null ) { @@ -1346,8 +1348,10 @@ export function unhideDehydratedBoundary( export function unhideInstance(instance: Instance, props: Props): void { instance = ((instance: any): HTMLElement); const styleProp = props[STYLE]; + // $FlowFixMe[invalid-compare] const display = styleProp !== undefined && + // $FlowFixMe[invalid-compare] styleProp !== null && styleProp.hasOwnProperty('display') ? styleProp.display @@ -3324,7 +3328,9 @@ function validateDocumentPositionWithFiberTree( if (documentPosition & Node.DOCUMENT_POSITION_CONTAINS) { if (otherFiber === null) { // otherFiber could be null if its the document or body element + // $FlowFixMe[invalid-compare] const ownerDocument = otherNode.ownerDocument; + // $FlowFixMe[invalid-compare] return otherNode === ownerDocument || otherNode === ownerDocument.body; } return isFragmentContainedByFiber(fragmentFiber, otherFiber); @@ -4438,7 +4444,7 @@ export function requestPostPaintCallback(callback: (time: number) => void) { // Singletons // ------------------- -export const supportsSingletons = true; +export const supportsSingletons: boolean = true; export function isHostSingletonType(type: string): boolean { return type === 'html' || type === 'head' || type === 'body'; @@ -4565,7 +4571,7 @@ export function releaseSingletonInstance(instance: Instance): void { // Resources // ------------------- -export const supportsResources = true; +export const supportsResources: boolean = true; type HoistableTagType = 'link' | 'meta' | 'title'; type TResource< diff --git a/packages/react-dom-bindings/src/client/validateDOMNesting.js b/packages/react-dom-bindings/src/client/validateDOMNesting.js index 47aef9353ba..ccf99d76a7e 100644 --- a/packages/react-dom-bindings/src/client/validateDOMNesting.js +++ b/packages/react-dom-bindings/src/client/validateDOMNesting.js @@ -418,6 +418,7 @@ function isTagValidWithParent( case 'rp': case 'rt': + // $FlowFixMe[incompatible-type] parentTag is nullable but indexOf handles it correctly return impliedEndTags.indexOf(parentTag) === -1; case 'caption': diff --git a/packages/react-dom-bindings/src/events/DOMPluginEventSystem.js b/packages/react-dom-bindings/src/events/DOMPluginEventSystem.js index e30c4798371..75471e444d3 100644 --- a/packages/react-dom-bindings/src/events/DOMPluginEventSystem.js +++ b/packages/react-dom-bindings/src/events/DOMPluginEventSystem.js @@ -446,6 +446,7 @@ export function listenToAllSupportedEvents(rootContainerElement: EventTarget) { (rootContainerElement: any).nodeType === DOCUMENT_NODE ? rootContainerElement : (rootContainerElement: any).ownerDocument; + // $FlowFixMe[invalid-compare] if (ownerDocument !== null) { // The selectionchange event also needs deduplication // but it is attached to the document. @@ -925,6 +926,8 @@ function accumulateEnterLeaveListenersForEvent( createDispatchListener(instance, captureListener, currentTarget), ); } + // $FlowFixMe[constant-condition] + // $FlowFixMe[invalid-compare] } else if (!inCapturePhase) { const bubbleListener = getListener(instance, registrationName); if (bubbleListener != null) { diff --git a/packages/react-dom-bindings/src/events/ReactDOMEventReplaying.js b/packages/react-dom-bindings/src/events/ReactDOMEventReplaying.js index 2763b2fc129..ed96173fa4e 100644 --- a/packages/react-dom-bindings/src/events/ReactDOMEventReplaying.js +++ b/packages/react-dom-bindings/src/events/ReactDOMEventReplaying.js @@ -215,7 +215,9 @@ function accumulateOrCreateContinuousQueuedReplayableEvent( // store a single event to be replayed. existingQueuedEvent.eventSystemFlags |= eventSystemFlags; const targetContainers = existingQueuedEvent.targetContainers; + // $FlowFixMe[invalid-compare] if ( + // $FlowFixMe[invalid-compare] targetContainer !== null && targetContainers.indexOf(targetContainer) === -1 ) { diff --git a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js index 9c6eb622e12..6c948931aa1 100644 --- a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js +++ b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js @@ -1560,6 +1560,7 @@ function pushAttribute( return; } case 'src': { + // $FlowFixMe[invalid-compare] if (enableSrcObject && typeof value === 'object' && value !== null) { if (typeof Blob === 'function' && value instanceof Blob) { pushSrcObjectAttribute(target, value); @@ -3562,7 +3563,10 @@ function pushTitle( ' tags to a single string value.', childType, ); + // $FlowFixMe[invalid-compare] + // $FlowFixMe[constant-condition] } else if (child && child.toString === {}.toString) { + // $FlowFixMe[invalid-compare] if (child.$$typeof != null) { console.error( 'React expects the `children` prop of tags to be a string, number, bigint, or object with a novel `toString` method but found an object that appears to be' + @@ -4018,8 +4022,10 @@ function pushStartCustomElement( typeof propValue !== 'function' && typeof propValue !== 'symbol' ) { + // $FlowFixMe[invalid-compare] if (propValue === false) { continue; + // $FlowFixMe[invalid-compare] } else if (propValue === true) { propValue = ''; } else if (typeof propValue === 'object') { @@ -4611,6 +4617,7 @@ export function writeStartPendingSuspenseBoundary( ): boolean { writeChunk(destination, startPendingSuspenseBoundary1); + // $FlowFixMe[invalid-compare] if (id === null) { throw new Error( 'An ID must have been assigned before we can complete the boundary.', diff --git a/packages/react-dom/src/client/ReactDOMRoot.js b/packages/react-dom/src/client/ReactDOMRoot.js index a32cefe81d5..c6b1aec71d2 100644 --- a/packages/react-dom/src/client/ReactDOMRoot.js +++ b/packages/react-dom/src/client/ReactDOMRoot.js @@ -187,15 +187,19 @@ export function createRoot( let onDefaultTransitionIndicator = defaultOnDefaultTransitionIndicator; let transitionCallbacks = null; + // $FlowFixMe[invalid-compare] if (options !== null && options !== undefined) { if (__DEV__) { + // $FlowFixMe[invalid-compare] if ((options: any).hydrate) { console.warn( 'hydrate through createRoot is deprecated. Use ReactDOMClient.hydrateRoot(container, <App />) instead.', ); } else { + // $FlowFixMe[invalid-compare] if ( typeof options === 'object' && + // $FlowFixMe[invalid-compare] options !== null && (options: any).$$typeof === REACT_ELEMENT_TYPE ) { @@ -304,6 +308,7 @@ export function hydrateRoot( let onDefaultTransitionIndicator = defaultOnDefaultTransitionIndicator; let transitionCallbacks = null; let formState = null; + // $FlowFixMe[invalid-compare] if (options !== null && options !== undefined) { if (options.unstable_strictMode === true) { isStrictMode = true; diff --git a/packages/react-dom/src/shared/ReactDOMFloat.js b/packages/react-dom/src/shared/ReactDOMFloat.js index 844824fd066..4d916308eb1 100644 --- a/packages/react-dom/src/shared/ReactDOMFloat.js +++ b/packages/react-dom/src/shared/ReactDOMFloat.js @@ -114,6 +114,7 @@ export function preload(href: string, options: PreloadOptions) { typeof href === 'string' && // We check existence because we cannot enforce this function is actually called with the stated type typeof options === 'object' && + // $FlowFixMe[invalid-compare] options !== null && typeof options.as === 'string' ) { diff --git a/packages/react-reconciler/src/ReactCapturedValue.js b/packages/react-reconciler/src/ReactCapturedValue.js index feb0a9f0752..d870fa02bf1 100644 --- a/packages/react-reconciler/src/ReactCapturedValue.js +++ b/packages/react-reconciler/src/ReactCapturedValue.js @@ -25,6 +25,7 @@ export function createCapturedValueAtFiber<T>( ): CapturedValue<T> { // If the value is an error, call this function immediately after it is thrown // so the stack is accurate. + // $FlowFixMe[invalid-compare] if (typeof value === 'object' && value !== null) { const existing = CapturedStacks.get(value); if (existing !== undefined) { diff --git a/packages/react-reconciler/src/ReactChildFiber.js b/packages/react-reconciler/src/ReactChildFiber.js index c5aeebeebf6..561bc3a3787 100644 --- a/packages/react-reconciler/src/ReactChildFiber.js +++ b/packages/react-reconciler/src/ReactChildFiber.js @@ -811,6 +811,7 @@ function createChildReconciler( return created; } + // $FlowFixMe[invalid-compare] if (newChild.$$typeof === REACT_CONTEXT_TYPE) { const context: ReactContext<mixed> = (newChild: any); return createChild( @@ -952,6 +953,7 @@ function createChildReconciler( return updated; } + // $FlowFixMe[invalid-compare] if (newChild.$$typeof === REACT_CONTEXT_TYPE) { const context: ReactContext<mixed> = (newChild: any); return updateSlot( @@ -1084,6 +1086,7 @@ function createChildReconciler( return updated; } + // $FlowFixMe[invalid-compare] if (newChild.$$typeof === REACT_CONTEXT_TYPE) { const context: ReactContext<mixed> = (newChild: any); return updateFromMap( @@ -1982,6 +1985,7 @@ function createChildReconciler( return firstChild; } + // $FlowFixMe[invalid-compare] if (newChild.$$typeof === REACT_CONTEXT_TYPE) { const context: ReactContext<mixed> = (newChild: any); return reconcileChildFibersImpl( diff --git a/packages/react-reconciler/src/ReactFiber.js b/packages/react-reconciler/src/ReactFiber.js index 7ab798ea22b..703fcd2ec48 100644 --- a/packages/react-reconciler/src/ReactFiber.js +++ b/packages/react-reconciler/src/ReactFiber.js @@ -588,22 +588,28 @@ export function createFiberFromTypeAndProps( : isHostSingletonType(type) ? HostSingleton : HostComponent; + // $FlowFixMe[constant-condition] supportsResources varies by build config } else if (supportsResources) { const hostContext = getHostContext(); fiberTag = isHostHoistableType(type, pendingProps, hostContext) ? HostHoistable : HostComponent; + // $FlowFixMe[constant-condition] supportsSingletons varies by build config } else if (supportsSingletons) { fiberTag = isHostSingletonType(type) ? HostSingleton : HostComponent; } else { fiberTag = HostComponent; } } else { + // $FlowFixMe[invalid-compare] type narrowed incorrectly due to constant conditions above getTag: switch (type) { + // $FlowFixMe[invalid-compare] case REACT_ACTIVITY_TYPE: return createFiberFromActivity(pendingProps, mode, lanes, key); + // $FlowFixMe[invalid-compare] case REACT_FRAGMENT_TYPE: return createFiberFromFragment(pendingProps.children, mode, lanes, key); + // $FlowFixMe[invalid-compare] case REACT_STRICT_MODE_TYPE: fiberTag = Mode; mode |= StrictLegacyMode; @@ -612,51 +618,64 @@ export function createFiberFromTypeAndProps( mode |= StrictEffectsMode; } break; + // $FlowFixMe[invalid-compare] case REACT_PROFILER_TYPE: return createFiberFromProfiler(pendingProps, mode, lanes, key); + // $FlowFixMe[invalid-compare] case REACT_SUSPENSE_TYPE: return createFiberFromSuspense(pendingProps, mode, lanes, key); + // $FlowFixMe[invalid-compare] case REACT_SUSPENSE_LIST_TYPE: return createFiberFromSuspenseList(pendingProps, mode, lanes, key); + // $FlowFixMe[invalid-compare] case REACT_LEGACY_HIDDEN_TYPE: if (enableLegacyHidden) { return createFiberFromLegacyHidden(pendingProps, mode, lanes, key); } // Fall through + // $FlowFixMe[invalid-compare] case REACT_VIEW_TRANSITION_TYPE: if (enableViewTransition) { return createFiberFromViewTransition(pendingProps, mode, lanes, key); } // Fall through + // $FlowFixMe[invalid-compare] case REACT_SCOPE_TYPE: if (enableScopeAPI) { return createFiberFromScope(type, pendingProps, mode, lanes, key); } // Fall through + // $FlowFixMe[invalid-compare] case REACT_TRACING_MARKER_TYPE: if (enableTransitionTracing) { return createFiberFromTracingMarker(pendingProps, mode, lanes, key); } // Fall through default: { + // $FlowFixMe[invalid-compare] if (typeof type === 'object' && type !== null) { switch (type.$$typeof) { + // $FlowFixMe[invalid-compare] case REACT_CONTEXT_TYPE: fiberTag = ContextProvider; break getTag; + // $FlowFixMe[invalid-compare] case REACT_CONSUMER_TYPE: fiberTag = ContextConsumer; break getTag; // Fall through + // $FlowFixMe[invalid-compare] case REACT_FORWARD_REF_TYPE: fiberTag = ForwardRef; if (__DEV__) { resolvedType = resolveForwardRefForHotReloading(resolvedType); } break getTag; + // $FlowFixMe[invalid-compare] case REACT_MEMO_TYPE: fiberTag = MemoComponent; break getTag; + // $FlowFixMe[invalid-compare] case REACT_LAZY_TYPE: fiberTag = LazyComponent; resolvedType = null; @@ -669,6 +688,7 @@ export function createFiberFromTypeAndProps( if ( type === undefined || (typeof type === 'object' && + // $FlowFixMe[invalid-compare] type !== null && Object.keys(type).length === 0) ) { @@ -677,12 +697,14 @@ export function createFiberFromTypeAndProps( "it's defined in, or you might have mixed up default and named imports."; } + // $FlowFixMe[invalid-compare] if (type === null) { typeString = 'null'; } else if (isArray(type)) { typeString = 'array'; } else if ( type !== undefined && + // $FlowFixMe[invalid-compare] type.$$typeof === REACT_ELEMENT_TYPE ) { typeString = `<${ @@ -699,6 +721,7 @@ export function createFiberFromTypeAndProps( info += '\n\nCheck the render method of `' + ownerName + '`.'; } } else { + // $FlowFixMe[invalid-compare] typeString = type === null ? 'null' : typeof type; } diff --git a/packages/react-reconciler/src/ReactFiberAct.js b/packages/react-reconciler/src/ReactFiberAct.js index b611d7472b0..9a6fb22c8c0 100644 --- a/packages/react-reconciler/src/ReactFiberAct.js +++ b/packages/react-reconciler/src/ReactFiberAct.js @@ -30,6 +30,7 @@ export function isLegacyActEnvironment(fiber: Fiber): boolean { // $FlowFixMe[cannot-resolve-name] - Flow doesn't know about jest const jestIsDefined = typeof jest !== 'undefined'; return ( + // $FlowFixMe[constant-condition] warnsIfNotActing && jestIsDefined && isReactActEnvironmentGlobal !== false ); } diff --git a/packages/react-reconciler/src/ReactFiberApplyGesture.js b/packages/react-reconciler/src/ReactFiberApplyGesture.js index f18e33b57ba..8df328c4f44 100644 --- a/packages/react-reconciler/src/ReactFiberApplyGesture.js +++ b/packages/react-reconciler/src/ReactFiberApplyGesture.js @@ -461,6 +461,7 @@ function recursivelyInsertNewFiber( } case HostText: { const textInstance: TextInstance = finishedWork.stateNode; + // $FlowFixMe[invalid-compare] if (textInstance === null) { throw new Error( 'This should have a text node initialized. This error is likely ' + @@ -602,6 +603,7 @@ function recursivelyInsertClonesFromExistingTree( } case HostText: { const textInstance: TextInstance = child.stateNode; + // $FlowFixMe[invalid-compare] if (textInstance === null) { throw new Error( 'This should have a text node initialized. This error is likely ' + @@ -875,6 +877,7 @@ function insertDestinationClonesOfFiber( } case HostText: { const textInstance: TextInstance = finishedWork.stateNode; + // $FlowFixMe[invalid-compare] if (textInstance === null) { throw new Error( 'This should have a text node initialized. This error is likely ' + @@ -919,6 +922,7 @@ function insertDestinationClonesOfFiber( parentViewTransition, nextPhase, ); + // $FlowFixMe[invalid-compare] } else if (current !== null && current.memoizedState === null) { // Was previously mounted as visible but is now hidden. trackEnterViewTransitions(current); @@ -1081,6 +1085,7 @@ function applyViewTransitionsOnFiber(finishedWork: Fiber) { const isHidden = newState !== null; if (!isHidden) { measureExitViewTransitions(finishedWork); + // $FlowFixMe[invalid-compare] } else if (current !== null && current.memoizedState === null) { // Was previously mounted as visible but is now hidden. commitEnterViewTransitions(current, true); @@ -1237,6 +1242,7 @@ function restoreViewTransitionsOnFiber(finishedWork: Fiber) { const isHidden = newState !== null; if (!isHidden) { restoreEnterOrExitViewTransitions(finishedWork); + // $FlowFixMe[invalid-compare] } else if (current !== null && current.memoizedState === null) { // Was previously mounted as visible but is now hidden. restoreEnterOrExitViewTransitions(current); diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.js b/packages/react-reconciler/src/ReactFiberBeginWork.js index ba401a55d4b..afc5453b63d 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.js @@ -1834,6 +1834,7 @@ function updateHostRoot( // Caution: React DevTools currently depends on this property // being called "element". const nextChildren = nextState.element; + // $FlowFixMe[constant-condition] if (supportsHydration && prevState.isDehydrated) { // This is a hydration root whose shell has not yet hydrated. We should // attempt to hydrate. @@ -1983,6 +1984,7 @@ function updateHostComponent( // and forms cannot be nested. If we did support nested providers, then // we would need to push a context value even for host fibers that // haven't been upgraded yet. + // $FlowFixMe[constant-condition] if (isPrimaryRenderer) { HostTransitionContext._currentValue = newState; } else { @@ -2117,8 +2119,10 @@ function mountLazyComponent( renderLanes, ); } + // $FlowFixMe[invalid-compare] } else if (Component !== undefined && Component !== null) { const $$typeof = Component.$$typeof; + // $FlowFixMe[invalid-compare] if ($$typeof === REACT_FORWARD_REF_TYPE) { workInProgress.tag = ForwardRef; if (__DEV__) { @@ -2132,6 +2136,7 @@ function mountLazyComponent( props, renderLanes, ); + // $FlowFixMe[invalid-compare] } else if ($$typeof === REACT_MEMO_TYPE) { workInProgress.tag = MemoComponent; return updateMemoComponent( @@ -2147,8 +2152,11 @@ function mountLazyComponent( let hint = ''; if (__DEV__) { if ( + // $FlowFixMe[invalid-compare] Component !== null && + // $FlowFixMe[invalid-compare] typeof Component === 'object' && + // $FlowFixMe[invalid-compare] Component.$$typeof === REACT_LAZY_TYPE ) { hint = ' Did you wrap a component in React.lazy() more than once?'; @@ -2264,7 +2272,9 @@ function updateSuspenseOffscreenState( ): OffscreenState { let cachePool: SpawnedCachePool | null = null; const prevCachePool: SpawnedCachePool | null = prevOffscreenState.cachePool; + // $FlowFixMe[invalid-compare] if (prevCachePool !== null) { + // $FlowFixMe[constant-condition] const parentCache = isPrimaryRenderer ? CacheContext._currentValue : CacheContext._currentValue2; @@ -2303,6 +2313,7 @@ function shouldRemainOnFallback( // whether the current fiber (if it exists) was visible in the previous tree. if (current !== null) { const suspenseState: SuspenseState = current.memoizedState; + // $FlowFixMe[invalid-compare] if (suspenseState === null) { // Currently showing content. Don't hide it, even if ForceSuspenseFallback // is true. More precise name might be "ForceRemainSuspenseFallback". @@ -3248,10 +3259,15 @@ function validateRevealOrder(revealOrder: SuspenseListRevealOrder) { ) { didWarnAboutRevealOrder[cacheKey] = true; if (typeof revealOrder === 'string') { + // $FlowFixMe[invalid-compare] switch (revealOrder.toLowerCase()) { + // $FlowFixMe[invalid-compare] case 'together': + // $FlowFixMe[invalid-compare] case 'forwards': + // $FlowFixMe[invalid-compare] case 'backwards': + // $FlowFixMe[invalid-compare] case 'independent': { console.error( '"%s" is not a valid value for revealOrder on <SuspenseList />. ' + @@ -3261,7 +3277,9 @@ function validateRevealOrder(revealOrder: SuspenseListRevealOrder) { ); break; } + // $FlowFixMe[invalid-compare] case 'forward': + // $FlowFixMe[invalid-compare] case 'backward': { console.error( '"%s" is not a valid value for revealOrder on <SuspenseList />. ' + @@ -3809,6 +3827,7 @@ function remountFiber( newWorkInProgress.return = oldWorkInProgress.return; newWorkInProgress.ref = oldWorkInProgress.ref; + // $FlowFixMe[constant-condition] if (__DEV__) { newWorkInProgress._debugInfo = oldWorkInProgress._debugInfo; } diff --git a/packages/react-reconciler/src/ReactFiberClassComponent.js b/packages/react-reconciler/src/ReactFiberClassComponent.js index 1fae90f07b1..47fc8fa9ac0 100644 --- a/packages/react-reconciler/src/ReactFiberClassComponent.js +++ b/packages/react-reconciler/src/ReactFiberClassComponent.js @@ -1070,6 +1070,7 @@ function updateClassInstance( !hasContextChanged() && !checkHasForceUpdateAfterProcessing() && !( + // $FlowFixMe[invalid-compare] current !== null && current.dependencies !== null && checkIfContextChanged(current.dependencies) @@ -1121,6 +1122,7 @@ function updateClassInstance( // both before and after `shouldComponentUpdate` has been called. Not ideal, // but I'm loath to refactor this function. This only happens for memoized // components so it's not that common. + // $FlowFixMe[invalid-compare] (current !== null && current.dependencies !== null && checkIfContextChanged(current.dependencies)); diff --git a/packages/react-reconciler/src/ReactFiberClassUpdateQueue.js b/packages/react-reconciler/src/ReactFiberClassUpdateQueue.js index 23bef1e6b09..21c3a6bb372 100644 --- a/packages/react-reconciler/src/ReactFiberClassUpdateQueue.js +++ b/packages/react-reconciler/src/ReactFiberClassUpdateQueue.js @@ -350,6 +350,7 @@ export function enqueueCapturedUpdate<State>( } while (update !== null); // Append the captured update the end of the cloned list. + // $FlowFixMe[invalid-compare] if (newLast === null) { newFirst = newLast = capturedUpdate; } else { @@ -672,6 +673,7 @@ export function processUpdateQueue<State>( queue.firstBaseUpdate = newFirstBaseUpdate; queue.lastBaseUpdate = newLastBaseUpdate; + // $FlowFixMe[invalid-compare] if (firstBaseUpdate === null) { // `queue.lanes` is used for entangling transitions. We can set it back to // zero once the queue is empty. diff --git a/packages/react-reconciler/src/ReactFiberCommitEffects.js b/packages/react-reconciler/src/ReactFiberCommitEffects.js index ba4fbe29763..7ae3dd1aa7f 100644 --- a/packages/react-reconciler/src/ReactFiberCommitEffects.js +++ b/packages/react-reconciler/src/ReactFiberCommitEffects.js @@ -195,6 +195,7 @@ export function commitHookEffectListMount( hookName = 'useEffect'; } let addendum; + // $FlowFixMe[invalid-compare] if (destroy === null) { addendum = ' You returned null. If your effect does not require clean ' + diff --git a/packages/react-reconciler/src/ReactFiberCommitHostEffects.js b/packages/react-reconciler/src/ReactFiberCommitHostEffects.js index 5c7ccf39878..915e3dd269f 100644 --- a/packages/react-reconciler/src/ReactFiberCommitHostEffects.js +++ b/packages/react-reconciler/src/ReactFiberCommitHostEffects.js @@ -508,6 +508,7 @@ function commitPlacement(finishedWork: Fiber): void { parentFiber = parentFiber.return; } + // $FlowFixMe[constant-condition] if (!supportsMutation) { if (enableFragmentRefs) { commitImmutablePlacementNodeToFragmentInstances( diff --git a/packages/react-reconciler/src/ReactFiberCommitViewTransitions.js b/packages/react-reconciler/src/ReactFiberCommitViewTransitions.js index 20abaa673c2..f7ce6415ec9 100644 --- a/packages/react-reconciler/src/ReactFiberCommitViewTransitions.js +++ b/packages/react-reconciler/src/ReactFiberCommitViewTransitions.js @@ -136,6 +136,7 @@ function applyViewTransitionToHostInstancesRecursive( collectMeasurements: null | Array<InstanceMeasurement>, stopAtNestedViewTransitions: boolean, ): boolean { + // $FlowFixMe[constant-condition] if (!supportsMutation) { return false; } @@ -198,6 +199,7 @@ function restoreViewTransitionOnHostInstances( child: null | Fiber, stopAtNestedViewTransitions: boolean, ): void { + // $FlowFixMe[constant-condition] if (!supportsMutation) { return; } @@ -645,6 +647,7 @@ function measureViewTransitionHostInstancesRecursive( previousMeasurements: null | Array<InstanceMeasurement>, stopAtNestedViewTransitions: boolean, ): boolean { + // $FlowFixMe[constant-condition] if (!supportsMutation) { return true; } diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js index 9c639c187a1..18eca37d988 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.js @@ -527,6 +527,7 @@ function commitBeforeMutationEffectsOnFiber( } case HostRoot: { if ((flags & Snapshot) !== NoFlags) { + // $FlowFixMe[constant-condition] if (supportsMutation) { const root = finishedWork.stateNode; clearContainer(root.containerInfo); @@ -973,6 +974,7 @@ function abortTracingMarkerTransitions( // If one of the transitions on the tracing marker is a transition // that was in an aborted subtree, we will abort that tracing marker if ( + // $FlowFixMe[invalid-compare] abortedFiber !== null && markerTransitions.has(transition) && (markerInstance.aborts === null || @@ -1185,6 +1187,7 @@ function commitTransitionProgress(offscreenFiber: Fiber) { } function hideOrUnhideAllChildren(parentFiber: Fiber, isHidden: boolean) { + // $FlowFixMe[constant-condition] if (!supportsMutation) { return; } @@ -1198,6 +1201,7 @@ function hideOrUnhideAllChildren(parentFiber: Fiber, isHidden: boolean) { } function hideOrUnhideAllChildrenOnFiber(fiber: Fiber, isHidden: boolean) { + // $FlowFixMe[constant-condition] if (!supportsMutation) { return; } @@ -1246,6 +1250,7 @@ function hideOrUnhideAllChildrenOnFiber(fiber: Fiber, isHidden: boolean) { } function hideOrUnhideNearestPortals(parentFiber: Fiber, isHidden: boolean) { + // $FlowFixMe[constant-condition] if (!supportsMutation) { return; } @@ -1259,6 +1264,7 @@ function hideOrUnhideNearestPortals(parentFiber: Fiber, isHidden: boolean) { } function hideOrUnhideNearestPortalsOnFiber(fiber: Fiber, isHidden: boolean) { + // $FlowFixMe[constant-condition] if (!supportsMutation) { return; } @@ -1331,8 +1337,10 @@ function detachFiberAfterEffects(fiber: Fiber) { // tree, which has its own pointers to children, parents, and siblings. // The other host nodes also point back to fibers, so we should detach that // one, too. + // $FlowFixMe[invalid-compare] if (fiber.tag === HostComponent) { const hostInstance: Instance = fiber.stateNode; + // $FlowFixMe[invalid-compare] if (hostInstance !== null) { detachDeletedInstance(hostInstance); } @@ -1370,6 +1378,7 @@ function commitDeletionEffects( ) { const prevEffectStart = pushComponentEffectStart(); + // $FlowFixMe[constant-condition] if (supportsMutation) { // We only have the top Fiber that was deleted but we need to recurse down its // children to find all the terminal nodes. @@ -1546,6 +1555,7 @@ function commitDeletionEffectsOnFiber( // We only need to remove the nearest host child. Set the host parent // to `null` on the stack to indicate that nested children don't // need to be removed. + // $FlowFixMe[constant-condition] if (supportsMutation) { const prevHostParent = hostParent; const prevHostParentIsContainer = hostParentIsContainer; @@ -1610,6 +1620,7 @@ function commitDeletionEffectsOnFiber( // Dehydrated fragments don't have any children // Delete the dehydrated suspense boundary and all of its content. + // $FlowFixMe[constant-condition] if (supportsMutation) { if (hostParent !== null) { if (hostParentIsContainer) { @@ -1628,6 +1639,7 @@ function commitDeletionEffectsOnFiber( break; } case HostPortal: { + // $FlowFixMe[constant-condition] if (supportsMutation) { // When we go into a portal, it becomes the parent to remove from. const prevHostParent = hostParent; @@ -1642,6 +1654,7 @@ function commitDeletionEffectsOnFiber( hostParent = prevHostParent; hostParentIsContainer = prevHostParentIsContainer; } else { + // $FlowFixMe[constant-condition] if (supportsPersistence) { commitHostPortalContainerChildren( deletedFiber.stateNode, @@ -1836,6 +1849,7 @@ function commitActivityHydrationCallbacks( finishedRoot: FiberRoot, finishedWork: Fiber, ) { + // $FlowFixMe[constant-condition] if (!supportsHydration) { return; } @@ -1870,6 +1884,7 @@ function commitSuspenseHydrationCallbacks( finishedRoot: FiberRoot, finishedWork: Fiber, ) { + // $FlowFixMe[constant-condition] if (!supportsHydration) { return; } @@ -2197,6 +2212,7 @@ function commitMutationEffectsOnFiber( safelyDetachRef(current, current.return); } } + // $FlowFixMe[constant-condition] if (supportsMutation) { // TODO: ContentReset gets cleared by the children during the commit // phase. This is a refactor hazard because it means we must read @@ -2236,7 +2252,9 @@ function commitMutationEffectsOnFiber( } } } else { + // $FlowFixMe[constant-condition] if (enableEagerAlternateStateNodeCleanup) { + // $FlowFixMe[constant-condition] if (supportsPersistence) { if (finishedWork.alternate !== null) { // `finishedWork.alternate.stateNode` is pointing to a stale shadow @@ -2257,6 +2275,7 @@ function commitMutationEffectsOnFiber( commitReconciliationEffects(finishedWork, lanes); if (flags & Update) { + // $FlowFixMe[constant-condition] if (supportsMutation) { if (finishedWork.stateNode === null) { throw new Error( @@ -2281,6 +2300,7 @@ function commitMutationEffectsOnFiber( const prevProfilerEffectDuration = pushNestedEffectDurations(); pushRootMutationContext(); + // $FlowFixMe[constant-condition] if (supportsResources) { prepareToCommitHoistables(); @@ -2297,6 +2317,7 @@ function commitMutationEffectsOnFiber( } if (flags & Update) { + // $FlowFixMe[constant-condition] if (supportsMutation && supportsHydration) { if (current !== null) { const prevRootState: RootState = current.memoizedState; @@ -2305,6 +2326,7 @@ function commitMutationEffectsOnFiber( } } } + // $FlowFixMe[constant-condition] if (supportsPersistence) { commitHostRootContainerChildren(root, finishedWork); } @@ -2364,6 +2386,7 @@ function commitMutationEffectsOnFiber( commitReconciliationEffects(finishedWork, lanes); currentHoistableRoot = previousHoistableRoot; } else { + // $FlowFixMe[constant-condition] recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork, lanes); } @@ -2378,6 +2401,7 @@ function commitMutationEffectsOnFiber( offscreenDirectParentIsHidden = prevOffscreenDirectParentIsHidden; if (flags & Update) { + // $FlowFixMe[constant-condition] if (supportsPersistence) { commitHostPortalContainerChildren( finishedWork.stateNode, @@ -2548,6 +2572,7 @@ function commitMutationEffectsOnFiber( if ( enableProfilerTimer && enableProfilerCommitHooks && + // $FlowFixMe[constant-condition] enableComponentPerformanceTrack && (finishedWork.mode & ProfileMode) !== NoMode && componentEffectStartTime >= 0 && @@ -2564,6 +2589,7 @@ function commitMutationEffectsOnFiber( } } + // $FlowFixMe[constant-condition] if (supportsMutation) { // If it's trying to unhide but the parent is still hidden, then we should not unhide. if (isHidden || !offscreenDirectParentIsHidden) { @@ -2593,6 +2619,7 @@ function commitMutationEffectsOnFiber( if (flags & Update) { const retryQueue: Set<Wakeable> | null = (finishedWork.updateQueue: any); + // $FlowFixMe[invalid-compare] if (retryQueue !== null) { finishedWork.updateQueue = null; attachSuspenseRetryListeners(finishedWork, retryQueue); @@ -2610,6 +2637,7 @@ function commitMutationEffectsOnFiber( const prevMutationContext = pushMutationContext(); const prevUpdate = inUpdateViewTransition; const isViewTransitionEligible = + // $FlowFixMe[constant-condition] enableViewTransition && includesOnlyViewTransitionEligibleLanes(lanes); const props = finishedWork.memoizedProps; @@ -3244,6 +3272,7 @@ export function reappearLayoutEffects( } case OffscreenComponent: { const offscreenState: OffscreenState = finishedWork.memoizedState; + // $FlowFixMe[invalid-compare] const isHidden = offscreenState !== null; if (isHidden) { // Nested Offscreen tree is still hidden. Don't re-appear its effects. @@ -3381,6 +3410,7 @@ function commitOffscreenPassiveMountEffects( const offscreenState: OffscreenState = finishedWork.memoizedState; const queue: OffscreenQueue | null = (finishedWork.updateQueue: any); + // $FlowFixMe[invalid-compare] const isHidden = offscreenState !== null; if (queue !== null) { if (isHidden) { @@ -3695,6 +3725,7 @@ function commitPassiveMountOnFiber( } if (isViewTransitionEligible) { + // $FlowFixMe[constant-condition] if (supportsMutation && rootViewTransitionNameCanceled) { restoreRootViewTransitionName(finishedRoot.containerInfo); } diff --git a/packages/react-reconciler/src/ReactFiberCompleteWork.js b/packages/react-reconciler/src/ReactFiberCompleteWork.js index 9b8c4a21bd8..f5679884ec2 100644 --- a/packages/react-reconciler/src/ReactFiberCompleteWork.js +++ b/packages/react-reconciler/src/ReactFiberCompleteWork.js @@ -205,6 +205,7 @@ function markUpdate(workInProgress: Fiber) { * it received an update that requires a clone of the tree above. */ function markCloned(workInProgress: Fiber) { + // $FlowFixMe[constant-condition] if (supportsPersistence) { workInProgress.flags |= Cloned; } @@ -245,6 +246,7 @@ function appendAllChildren( needsVisibilityToggle: boolean, isHidden: boolean, ) { + // $FlowFixMe[constant-condition] if (supportsMutation) { // We only have the top Fiber that was created but we need recurse down its // children to find all the terminal nodes. @@ -280,6 +282,7 @@ function appendAllChildren( node.sibling.return = node.return; node = node.sibling; } + // $FlowFixMe[constant-condition] } else if (supportsPersistence) { // We only have the top Fiber that was created but we need recurse down its // children to find all the terminal nodes. @@ -357,6 +360,7 @@ function appendAllChildrenToContainer( // about their presence, we track and return if they were added to the // child set. let hasOffscreenComponentChild = false; + // $FlowFixMe[constant-condition] if (supportsPersistence) { // We only have the top Fiber that was created but we need recurse down its // children to find all the terminal nodes. @@ -428,6 +432,7 @@ function appendAllChildrenToContainer( } function updateHostContainer(current: null | Fiber, workInProgress: Fiber) { + // $FlowFixMe[constant-condition] if (supportsPersistence) { if (doesRequireClone(current, workInProgress)) { const portalOrRoot: { @@ -459,6 +464,7 @@ function updateHostComponent( newProps: Props, renderLanes: Lanes, ) { + // $FlowFixMe[constant-condition] if (supportsMutation) { // If we have an alternate, that means this is an update and we need to // schedule a side-effect to do the updates. @@ -470,6 +476,7 @@ function updateHostComponent( } markUpdate(workInProgress); + // $FlowFixMe[constant-condition] } else if (supportsPersistence) { const currentInstance = current.stateNode; const oldProps = current.memoizedProps; @@ -667,11 +674,13 @@ function updateHostText( oldText: string, newText: string, ) { + // $FlowFixMe[constant-condition] if (supportsMutation) { // If the text differs, mark it as an update. All the work in done in commitWork. if (oldText !== newText) { markUpdate(workInProgress); } + // $FlowFixMe[constant-condition] } else if (supportsPersistence) { if (oldText !== newText) { // If the text content differs, we'll create a new text instance for it. @@ -922,6 +931,7 @@ function completeDehydratedActivityBoundary( bubbleProperties(workInProgress); if (enableProfilerTimer) { if ((workInProgress.mode & ProfileMode) !== NoMode) { + // $FlowFixMe[invalid-compare] const isTimedOutSuspense = nextState !== null; if (isTimedOutSuspense) { // Don't count time spent in a timed out Suspense subtree as part of the base duration. @@ -953,6 +963,7 @@ function completeDehydratedActivityBoundary( bubbleProperties(workInProgress); if (enableProfilerTimer) { if ((workInProgress.mode & ProfileMode) !== NoMode) { + // $FlowFixMe[invalid-compare] const isTimedOutSuspense = nextState !== null; if (isTimedOutSuspense) { // Don't count time spent in a timed out Suspense subtree as part of the base duration. @@ -1004,6 +1015,7 @@ function completeDehydratedSuspenseBoundary( bubbleProperties(workInProgress); if (enableProfilerTimer) { if ((workInProgress.mode & ProfileMode) !== NoMode) { + // $FlowFixMe[invalid-compare] const isTimedOutSuspense = nextState !== null; if (isTimedOutSuspense) { // Don't count time spent in a timed out Suspense subtree as part of the base duration. @@ -1035,6 +1047,7 @@ function completeDehydratedSuspenseBoundary( bubbleProperties(workInProgress); if (enableProfilerTimer) { if ((workInProgress.mode & ProfileMode) !== NoMode) { + // $FlowFixMe[invalid-compare] const isTimedOutSuspense = nextState !== null; if (isTimedOutSuspense) { // Don't count time spent in a timed out Suspense subtree as part of the base duration. @@ -1253,6 +1266,7 @@ function completeWork( const oldProps = current.memoizedProps; // This is an Instance // We may have props to update on the Hoistable instance. + // $FlowFixMe[constant-condition] if (supportsMutation) { if (oldProps !== newProps) { markUpdate(workInProgress); @@ -1289,6 +1303,7 @@ function completeWork( const rootContainerInstance = getRootHostContainer(); const type = workInProgress.type; if (current !== null && workInProgress.stateNode != null) { + // $FlowFixMe[constant-condition] if (supportsMutation) { const oldProps = current.memoizedProps; if (oldProps !== newProps) { diff --git a/packages/react-reconciler/src/ReactFiberConcurrentUpdates.js b/packages/react-reconciler/src/ReactFiberConcurrentUpdates.js index 05aeb3cfbb3..a782c89016d 100644 --- a/packages/react-reconciler/src/ReactFiberConcurrentUpdates.js +++ b/packages/react-reconciler/src/ReactFiberConcurrentUpdates.js @@ -64,6 +64,7 @@ export function finishQueueingConcurrentUpdates(): void { const lane: Lane = concurrentQueues[i]; concurrentQueues[i++] = null; + // $FlowFixMe[invalid-compare] if (queue !== null && update !== null) { const pending = queue.pending; if (pending === null) { diff --git a/packages/react-reconciler/src/ReactFiberConfigWithNoResources.js b/packages/react-reconciler/src/ReactFiberConfigWithNoResources.js index 0ab629a20ee..ad48e635373 100644 --- a/packages/react-reconciler/src/ReactFiberConfigWithNoResources.js +++ b/packages/react-reconciler/src/ReactFiberConfigWithNoResources.js @@ -22,7 +22,7 @@ export type HoistableRoot = mixed; export type Resource = mixed; // Resources (when unsupported) -export const supportsResources = false; +export const supportsResources: boolean = false; export const isHostHoistableType = shim; export const getHoistableRoot = shim; export const getResource = shim; diff --git a/packages/react-reconciler/src/ReactFiberConfigWithNoSingletons.js b/packages/react-reconciler/src/ReactFiberConfigWithNoSingletons.js index 92d2fadd39b..782e8f1c8ee 100644 --- a/packages/react-reconciler/src/ReactFiberConfigWithNoSingletons.js +++ b/packages/react-reconciler/src/ReactFiberConfigWithNoSingletons.js @@ -19,7 +19,7 @@ function shim(...args: any): any { } // Resources (when unsupported) -export const supportsSingletons = false; +export const supportsSingletons: boolean = false; export const resolveSingletonInstance = shim; export const acquireSingletonInstance = shim; export const releaseSingletonInstance = shim; diff --git a/packages/react-reconciler/src/ReactFiberHooks.js b/packages/react-reconciler/src/ReactFiberHooks.js index b04f68da7af..e76bda29a16 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.js +++ b/packages/react-reconciler/src/ReactFiberHooks.js @@ -1149,6 +1149,7 @@ function useThenable<T>(thenable: Thenable<T>): T { } function use<T>(usable: Usable<T>): T { + // $FlowFixMe[invalid-compare] if (usable !== null && typeof usable === 'object') { // $FlowFixMe[method-unbinding] if (typeof usable.then === 'function') { @@ -1527,6 +1528,7 @@ function updateReducerImpl<S, A>( } } update = update.next; + // $FlowFixMe[invalid-compare] } while (update !== null && update !== first); if (newBaseQueueLast === null) { @@ -2473,6 +2475,7 @@ function updateActionStateImpl<S, P>( let state: Awaited<S>; if ( typeof actionResult === 'object' && + // $FlowFixMe[invalid-compare] actionResult !== null && // $FlowFixMe[method-unbinding] typeof actionResult.then === 'function' @@ -2837,6 +2840,7 @@ function mountImperativeHandle<T>( console.error( 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', + // $FlowFixMe[invalid-compare] create !== null ? typeof create : 'null', ); } @@ -2871,6 +2875,7 @@ function updateImperativeHandle<T>( console.error( 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', + // $FlowFixMe[invalid-compare] create !== null ? typeof create : 'null', ); } diff --git a/packages/react-reconciler/src/ReactFiberHostContext.js b/packages/react-reconciler/src/ReactFiberHostContext.js index 2d2ec4c88ac..5b8be7008a2 100644 --- a/packages/react-reconciler/src/ReactFiberHostContext.js +++ b/packages/react-reconciler/src/ReactFiberHostContext.js @@ -105,6 +105,7 @@ function pushHostContext(fiber: Fiber): void { // we would need to push a context value even for host fibers that // haven't been upgraded yet. const transitionStatus: TransitionStatus = stateHook.memoizedState; + // $FlowFixMe[constant-condition] if (isPrimaryRenderer) { HostTransitionContext._currentValue = transitionStatus; } else { @@ -149,6 +150,7 @@ function popHostContext(fiber: Fiber): void { // to `NotPendingTransition`. We can do this because you're not allowed to nest forms. If // we allowed for multiple nested host transition providers, then we'd // need to reset this to the parent provider's status. + // $FlowFixMe[constant-condition] if (isPrimaryRenderer) { HostTransitionContext._currentValue = NotPendingTransition; } else { diff --git a/packages/react-reconciler/src/ReactFiberHydrationContext.js b/packages/react-reconciler/src/ReactFiberHydrationContext.js index 00e2fcddfcf..d8a46582d6e 100644 --- a/packages/react-reconciler/src/ReactFiberHydrationContext.js +++ b/packages/react-reconciler/src/ReactFiberHydrationContext.js @@ -160,6 +160,7 @@ export function markDidThrowWhileHydratingDEV() { } function enterHydrationState(fiber: Fiber): boolean { + // $FlowFixMe[constant-condition] if (!supportsHydration) { return false; } @@ -181,6 +182,7 @@ function reenterHydrationStateFromDehydratedActivityInstance( activityInstance: ActivityInstance, treeContext: TreeContext | null, ): boolean { + // $FlowFixMe[constant-condition] if (!supportsHydration) { return false; } @@ -203,6 +205,7 @@ function reenterHydrationStateFromDehydratedSuspenseInstance( suspenseInstance: SuspenseInstance, treeContext: TreeContext | null, ): boolean { + // $FlowFixMe[constant-condition] if (!supportsHydration) { return false; } @@ -542,6 +545,7 @@ function prepareToHydrateHostInstance( fiber: Fiber, hostContext: HostContext, ): void { + // $FlowFixMe[constant-condition] if (!supportsHydration) { throw new Error( 'Expected prepareToHydrateHostInstance() to never be called. ' + @@ -563,6 +567,7 @@ function prepareToHydrateHostInstance( } function prepareToHydrateHostTextInstance(fiber: Fiber): void { + // $FlowFixMe[constant-condition] if (!supportsHydration) { throw new Error( 'Expected prepareToHydrateHostTextInstance() to never be called. ' + @@ -629,6 +634,7 @@ function prepareToHydrateHostTextInstance(fiber: Fiber): void { } function prepareToHydrateHostActivityInstance(fiber: Fiber): void { + // $FlowFixMe[constant-condition] if (!supportsHydration) { throw new Error( 'Expected prepareToHydrateHostActivityInstance() to never be called. ' + @@ -650,6 +656,7 @@ function prepareToHydrateHostActivityInstance(fiber: Fiber): void { } function prepareToHydrateHostSuspenseInstance(fiber: Fiber): void { + // $FlowFixMe[constant-condition] if (!supportsHydration) { throw new Error( 'Expected prepareToHydrateHostSuspenseInstance() to never be called. ' + @@ -691,6 +698,7 @@ function skipPastDehydratedActivityInstance( function skipPastDehydratedSuspenseInstance( fiber: Fiber, ): null | HydratableInstance { + // $FlowFixMe[constant-condition] if (!supportsHydration) { throw new Error( 'Expected skipPastDehydratedSuspenseInstance() to never be called. ' + @@ -731,6 +739,7 @@ function popToNextHostParent(fiber: Fiber): void { } function popHydrationState(fiber: Fiber): boolean { + // $FlowFixMe[constant-condition] if (!supportsHydration) { return false; } @@ -824,6 +833,7 @@ function warnIfUnhydratedTailNodes(fiber: Fiber) { } function resetHydrationState(): void { + // $FlowFixMe[constant-condition] if (!supportsHydration) { return; } diff --git a/packages/react-reconciler/src/ReactFiberLane.js b/packages/react-reconciler/src/ReactFiberLane.js index 7ec53c096a5..dbcd04074a8 100644 --- a/packages/react-reconciler/src/ReactFiberLane.js +++ b/packages/react-reconciler/src/ReactFiberLane.js @@ -937,6 +937,7 @@ export function markRootFinished( // commits, they behave like regular updates. for (let i = 0; i < hiddenUpdatesForLane.length; i++) { const update = hiddenUpdatesForLane[i]; + // $FlowFixMe[invalid-compare] if (update !== null) { update.lane &= ~OffscreenLane; } diff --git a/packages/react-reconciler/src/ReactFiberNewContext.js b/packages/react-reconciler/src/ReactFiberNewContext.js index 81c47d7b649..b2313b5c422 100644 --- a/packages/react-reconciler/src/ReactFiberNewContext.js +++ b/packages/react-reconciler/src/ReactFiberNewContext.js @@ -80,6 +80,7 @@ export function pushProvider<T>( context: ReactContext<T>, nextValue: T, ): void { + // $FlowFixMe[constant-condition] if (isPrimaryRenderer) { push(valueCursor, context._currentValue, providerFiber); @@ -127,6 +128,7 @@ export function popProvider( ): void { const currentValue = valueCursor.current; + // $FlowFixMe[constant-condition] if (isPrimaryRenderer) { context._currentValue = currentValue; if (__DEV__) { @@ -232,6 +234,7 @@ function propagateContextChanges<T>( findContext: for (let i = 0; i < contexts.length; i++) { const context: ReactContext<T> = contexts[i]; // Check if the context matches. + // $FlowFixMe[invalid-compare] if (dependency.context === context) { // Match! Schedule an update on this fiber. @@ -473,6 +476,7 @@ export function checkIfContextChanged( let dependency = currentDependencies.firstContext; while (dependency !== null) { const context = dependency.context; + // $FlowFixMe[constant-condition] const newValue = isPrimaryRenderer ? context._currentValue : context._currentValue2; @@ -530,6 +534,7 @@ function readContextForConsumer<T>( consumer: Fiber | null, context: ReactContext<T>, ): T { + // $FlowFixMe[constant-condition] const value = isPrimaryRenderer ? context._currentValue : context._currentValue2; diff --git a/packages/react-reconciler/src/ReactFiberRootScheduler.js b/packages/react-reconciler/src/ReactFiberRootScheduler.js index 26b62552276..cc97e21d54c 100644 --- a/packages/react-reconciler/src/ReactFiberRootScheduler.js +++ b/packages/react-reconciler/src/ReactFiberRootScheduler.js @@ -662,6 +662,7 @@ function scheduleImmediateRootScheduleTask() { // TODO: Can we land supportsMicrotasks? Which environments don't support it? // Alternatively, can we move this check to the host config? + // $FlowFixMe[constant-condition] if (supportsMicrotasks) { scheduleMicrotask(() => { // In Safari, appending an iframe forces microtasks to run. diff --git a/packages/react-reconciler/src/ReactFiberScope.js b/packages/react-reconciler/src/ReactFiberScope.js index 8f9f1cdea57..ae5fda91561 100644 --- a/packages/react-reconciler/src/ReactFiberScope.js +++ b/packages/react-reconciler/src/ReactFiberScope.js @@ -40,6 +40,7 @@ function collectScopedNodes( const {type, memoizedProps, stateNode} = node; const instance = getPublicInstance(stateNode); if ( + // $FlowFixMe[invalid-compare] instance !== null && fn(type, memoizedProps || emptyObject, instance) === true ) { @@ -65,6 +66,7 @@ function collectFirstScopedNode( if (node.tag === HostComponent) { const {type, memoizedProps, stateNode} = node; const instance = getPublicInstance(stateNode); + // $FlowFixMe[invalid-compare] if (instance !== null && fn(type, memoizedProps, instance) === true) { return instance; } diff --git a/packages/react-reconciler/src/ReactFiberSuspenseComponent.js b/packages/react-reconciler/src/ReactFiberSuspenseComponent.js index 695c3697154..dea7812a035 100644 --- a/packages/react-reconciler/src/ReactFiberSuspenseComponent.js +++ b/packages/react-reconciler/src/ReactFiberSuspenseComponent.js @@ -62,6 +62,7 @@ export type RetryQueue = Set<Wakeable>; export function findFirstSuspended(row: Fiber): null | Fiber { let node = row; + // $FlowFixMe[invalid-compare] while (node !== null) { if (node.tag === SuspenseComponent) { const state: SuspenseState | null = node.memoizedState; diff --git a/packages/react-reconciler/src/ReactFiberSuspenseContext.js b/packages/react-reconciler/src/ReactFiberSuspenseContext.js index aec47af4656..3abea66ba60 100644 --- a/packages/react-reconciler/src/ReactFiberSuspenseContext.js +++ b/packages/react-reconciler/src/ReactFiberSuspenseContext.js @@ -92,6 +92,7 @@ export function pushPrimaryTreeSuspenseHandler(handler: Fiber): void { shellBoundary = handler; } else { const prevState: SuspenseState = current.memoizedState; + // $FlowFixMe[invalid-compare] if (prevState !== null) { // This boundary is showing a fallback in the current UI. shellBoundary = handler; diff --git a/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.js b/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.js index a54025294bb..8fbf5aefd3d 100644 --- a/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.js +++ b/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.js @@ -63,6 +63,7 @@ export function processTransitionCallbacks( callbacks: TransitionTracingCallbacks, ): void { if (enableTransitionTracing) { + // $FlowFixMe[invalid-compare] if (pendingTransitions !== null) { const transitionStart = pendingTransitions.transitionStart; const onTransitionStart = callbacks.onTransitionStart; @@ -78,9 +79,11 @@ export function processTransitionCallbacks( const onMarkerProgress = callbacks.onMarkerProgress; if (onMarkerProgress != null && markerProgress !== null) { markerProgress.forEach((markerInstance, markerName) => { + // $FlowFixMe[invalid-compare] if (markerInstance.transitions !== null) { // TODO: Clone the suspense object so users can't modify it const pending = + // $FlowFixMe[invalid-compare] markerInstance.pendingBoundaries !== null ? Array.from(markerInstance.pendingBoundaries.values()) : []; diff --git a/packages/react-reconciler/src/ReactFiberTransition.js b/packages/react-reconciler/src/ReactFiberTransition.js index 180a09b3659..a4d4190d0d4 100644 --- a/packages/react-reconciler/src/ReactFiberTransition.js +++ b/packages/react-reconciler/src/ReactFiberTransition.js @@ -135,6 +135,7 @@ function chainGestureCancellation( prevCancel: null | (() => void), ): () => void { return function cancelGesture(): void { + // $FlowFixMe[invalid-compare] if (scheduledGesture !== null) { cancelScheduledGesture(root, scheduledGesture); } @@ -245,6 +246,7 @@ export function requestCacheFromPool(renderLanes: Lanes): Cache { const freshCache = createCache(); root.pooledCache = freshCache; retainCache(freshCache); + // $FlowFixMe[invalid-compare] if (freshCache !== null) { root.pooledCacheLanes |= renderLanes; } @@ -329,6 +331,7 @@ export function getSuspendedCache(): SpawnedCachePool | null { return { // We must also save the parent, so that when we resume we can detect // a refresh. + // $FlowFixMe[constant-condition] parent: isPrimaryRenderer ? CacheContext._currentValue : CacheContext._currentValue2, @@ -345,6 +348,7 @@ export function getOffscreenDeferredCache(): SpawnedCachePool | null { return { // We must also store the parent, so that when we resume we can detect // a refresh. + // $FlowFixMe[constant-condition] parent: isPrimaryRenderer ? CacheContext._currentValue : CacheContext._currentValue2, diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.js b/packages/react-reconciler/src/ReactFiberWorkLoop.js index 53eb149b3ca..f3179bd8d06 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js @@ -1264,6 +1264,7 @@ function recoverFromConcurrentError( // Before rendering again, save the errors from the previous attempt. const errorsFromFirstAttempt = workInProgressRootConcurrentErrors; + // $FlowFixMe[constant-condition] const wasRootDehydrated = supportsHydration && isRootDehydrated(root); if (wasRootDehydrated) { // The shell failed to hydrate. Set a flag to force a client rendering @@ -4196,6 +4197,7 @@ function flushSpawnedWork(): void { // Eagerly flush any event replaying that we unblocked within this commit. // This ensures that those are observed before we render any new changes. + // $FlowFixMe[constant-condition] if (supportsHydration) { flushHydrationEvents(); } diff --git a/packages/react-reconciler/src/ReactTestSelectors.js b/packages/react-reconciler/src/ReactTestSelectors.js index ec30b2112b2..03b12bea796 100644 --- a/packages/react-reconciler/src/ReactTestSelectors.js +++ b/packages/react-reconciler/src/ReactTestSelectors.js @@ -307,6 +307,7 @@ export function findAllNodes( hostRoot: Instance, selectors: Array<Selector>, ): Array<Instance> { + // $FlowFixMe[constant-condition] if (!supportsTestSelectors) { throw new Error('Test selector API is not supported by this renderer.'); } @@ -346,6 +347,7 @@ export function getFindAllNodesFailureDescription( hostRoot: Instance, selectors: Array<Selector>, ): string | null { + // $FlowFixMe[constant-condition] if (!supportsTestSelectors) { throw new Error('Test selector API is not supported by this renderer.'); } @@ -417,6 +419,7 @@ export function findBoundingRects( hostRoot: Instance, selectors: Array<Selector>, ): Array<BoundingRect> { + // $FlowFixMe[constant-condition] if (!supportsTestSelectors) { throw new Error('Test selector API is not supported by this renderer.'); } @@ -507,6 +510,7 @@ export function focusWithin( hostRoot: Instance, selectors: Array<Selector>, ): boolean { + // $FlowFixMe[constant-condition] if (!supportsTestSelectors) { throw new Error('Test selector API is not supported by this renderer.'); } @@ -545,6 +549,7 @@ export function focusWithin( const commitHooks: Array<Function> = []; export function onCommitRoot(): void { + // $FlowFixMe[constant-condition] if (supportsTestSelectors) { commitHooks.forEach(commitHook => commitHook()); } @@ -562,6 +567,7 @@ export function observeVisibleRects( callback: (intersections: Array<{ratio: number, rect: BoundingRect}>) => void, options?: IntersectionObserverOptions, ): {disconnect: () => void} { + // $FlowFixMe[constant-condition] if (!supportsTestSelectors) { throw new Error('Test selector API is not supported by this renderer.'); } diff --git a/packages/react-server/src/ReactFizzComponentStack.js b/packages/react-server/src/ReactFizzComponentStack.js index 467cf48646c..9b55480a038 100644 --- a/packages/react-server/src/ReactFizzComponentStack.js +++ b/packages/react-server/src/ReactFizzComponentStack.js @@ -65,6 +65,7 @@ function describeComponentStackByType( return describeFunctionComponentFrame(type); } } + // $FlowFixMe[invalid-compare] if (typeof type === 'object' && type !== null) { switch (type.$$typeof) { case REACT_FORWARD_REF_TYPE: { diff --git a/packages/react-server/src/ReactFizzHooks.js b/packages/react-server/src/ReactFizzHooks.js index 9dfd5c3c2b7..d109be8942f 100644 --- a/packages/react-server/src/ReactFizzHooks.js +++ b/packages/react-server/src/ReactFizzHooks.js @@ -361,6 +361,7 @@ export function useReducer<S, I, A>( init?: I => S, ): [S, Dispatch<A>] { if (__DEV__) { + // $FlowFixMe[invalid-compare] if (reducer !== basicStateReducer) { currentHookNameInDev = 'useReducer'; } @@ -410,6 +411,7 @@ export function useReducer<S, I, A>( isInHookUserCodeInDev = true; } let initialState; + // $FlowFixMe[invalid-compare] if (reducer === basicStateReducer) { // Special case for `useState`. initialState = @@ -446,6 +448,7 @@ function useMemo<T>(nextCreate: () => T, deps: Array<mixed> | void | null): T { const nextDeps = deps === undefined ? null : deps; + // $FlowFixMe[invalid-compare] if (workInProgressHook !== null) { const prevState = workInProgressHook.memoizedState; if (prevState !== null) { @@ -748,6 +751,7 @@ function useId(): string { } function use<T>(usable: Usable<T>): T { + // $FlowFixMe[invalid-compare] if (usable !== null && typeof usable === 'object') { // $FlowFixMe[method-unbinding] if (typeof usable.then === 'function') { @@ -805,6 +809,7 @@ function clientHookNotSupported() { ); } +// $FlowFixMe[constant-condition] export const HooksDispatcher: Dispatcher = supportsClientAPIs ? { readContext, diff --git a/packages/react-server/src/ReactFizzNewContext.js b/packages/react-server/src/ReactFizzNewContext.js index f563091401c..2c9e4648ef1 100644 --- a/packages/react-server/src/ReactFizzNewContext.js +++ b/packages/react-server/src/ReactFizzNewContext.js @@ -39,6 +39,7 @@ export const rootContextSnapshot: ContextSnapshot = null; let currentActiveSnapshot: ContextSnapshot = null; function popNode(prev: ContextNode<any>): void { + // $FlowFixMe[constant-condition] if (isPrimaryRenderer) { prev.context._currentValue = prev.parentValue; } else { @@ -47,6 +48,7 @@ function popNode(prev: ContextNode<any>): void { } function pushNode(next: ContextNode<any>): void { + // $FlowFixMe[constant-condition] if (isPrimaryRenderer) { next.context._currentValue = next.value; } else { @@ -183,6 +185,7 @@ export function pushProvider<T>( nextValue: T, ): ContextSnapshot { let prevValue; + // $FlowFixMe[constant-condition] if (isPrimaryRenderer) { prevValue = context._currentValue; context._currentValue = nextValue; @@ -244,6 +247,7 @@ export function popProvider<T>(context: ReactContext<T>): ContextSnapshot { ); } } + // $FlowFixMe[constant-condition] if (isPrimaryRenderer) { const value = prevSnapshot.parentValue; prevSnapshot.context._currentValue = value; @@ -285,6 +289,7 @@ export function getActiveContext(): ContextSnapshot { } export function readContext<T>(context: ReactContext<T>): T { + // $FlowFixMe[constant-condition] const value = isPrimaryRenderer ? context._currentValue : context._currentValue2; diff --git a/packages/react-server/src/ReactFizzServer.js b/packages/react-server/src/ReactFizzServer.js index a99d245bb0c..7d99570a0b4 100644 --- a/packages/react-server/src/ReactFizzServer.js +++ b/packages/react-server/src/ReactFizzServer.js @@ -773,6 +773,7 @@ let currentRequest: null | Request = null; export function resolveRequest(): null | Request { if (currentRequest) return currentRequest; + // $FlowFixMe[constant-condition] if (supportsRequestStorage) { const store = requestStorage.getStore(); if (store) return store; @@ -2085,6 +2086,7 @@ function renderSuspenseList( let done = false; + // $FlowFixMe[invalid-compare] if (iterator === children) { // If it's an iterator we need to continue reading where we left // off. We can do that by reading the first few rows from the previous @@ -2852,9 +2854,13 @@ function renderElement( // TODO: Delete in LegacyHidden. It's an unstable API only used in the // www build. As a migration step, we could add a special prop to Offscreen // that simulates the old behavior (no hiding, no change to effects). + // $FlowFixMe[invalid-compare] case REACT_LEGACY_HIDDEN_TYPE: + // $FlowFixMe[invalid-compare] case REACT_STRICT_MODE_TYPE: + // $FlowFixMe[invalid-compare] case REACT_PROFILER_TYPE: + // $FlowFixMe[invalid-compare] case REACT_FRAGMENT_TYPE: { const prevKeyPath = task.keyPath; task.keyPath = keyPath; @@ -2862,14 +2868,17 @@ function renderElement( task.keyPath = prevKeyPath; return; } + // $FlowFixMe[invalid-compare] case REACT_ACTIVITY_TYPE: { renderActivity(request, task, keyPath, props); return; } + // $FlowFixMe[invalid-compare] case REACT_SUSPENSE_LIST_TYPE: { renderSuspenseList(request, task, keyPath, props); return; } + // $FlowFixMe[invalid-compare] case REACT_VIEW_TRANSITION_TYPE: { if (enableViewTransition) { renderViewTransition(request, task, keyPath, props); @@ -2877,6 +2886,7 @@ function renderElement( } // Fallthrough } + // $FlowFixMe[invalid-compare] case REACT_SCOPE_TYPE: { if (enableScopeAPI) { const prevKeyPath = task.keyPath; @@ -2887,33 +2897,40 @@ function renderElement( } throw new Error('ReactDOMServer does not yet support scope components.'); } + // $FlowFixMe[invalid-compare] case REACT_SUSPENSE_TYPE: { renderSuspenseBoundary(request, task, keyPath, props); return; } } + // $FlowFixMe[invalid-compare] if (typeof type === 'object' && type !== null) { switch (type.$$typeof) { + // $FlowFixMe[invalid-compare] case REACT_FORWARD_REF_TYPE: { renderForwardRef(request, task, keyPath, type, props, ref); return; } + // $FlowFixMe[invalid-compare] case REACT_MEMO_TYPE: { renderMemo(request, task, keyPath, type, props, ref); return; } + // $FlowFixMe[invalid-compare] case REACT_CONTEXT_TYPE: { const context = type; renderContextProvider(request, task, keyPath, context, props); return; } + // $FlowFixMe[invalid-compare] case REACT_CONSUMER_TYPE: { const context: ReactContext<any> = (type: ReactConsumerType<any>) ._context; renderContextConsumer(request, task, keyPath, context, props); return; } + // $FlowFixMe[invalid-compare] case REACT_LAZY_TYPE: { renderLazyComponent(request, task, keyPath, type, props, ref); return; @@ -2925,7 +2942,9 @@ function renderElement( if (__DEV__) { if ( type === undefined || + // $FlowFixMe[invalid-compare] (typeof type === 'object' && + // $FlowFixMe[invalid-compare] type !== null && Object.keys(type).length === 0) ) { @@ -3411,6 +3430,7 @@ function retryNode(request: Request, task: Task): void { let done = false; + // $FlowFixMe[invalid-compare] if (iterator === node) { // If it's an iterator we need to continue reading where we left // off. We can do that by reading the first few rows from the previous @@ -3846,6 +3866,7 @@ function trackPostpone( return; } + // $FlowFixMe[invalid-compare] if (boundary !== null && boundary.status === PENDING) { const boundaryNode = trackPostponedBoundary( request, @@ -3877,6 +3898,7 @@ function trackPostpone( // We know that this will leave a hole so we might as well assign an ID now. // We might have one already if we had a parent that gave us its ID. if (segment.id === -1) { + // $FlowFixMe[invalid-compare] if (segment.parentFlushed && boundary !== null) { // If this segment's parent was already flushed, it means we really just // skipped the parent and this segment is now the root. @@ -4089,6 +4111,7 @@ function renderNode( if (request.status === ABORTING) { // We are aborting so we can just bubble up to the task by falling through + // $FlowFixMe[invalid-compare] } else if (typeof x === 'object' && x !== null) { // $FlowFixMe[method-unbinding] if (typeof x.then === 'function') { @@ -4190,6 +4213,7 @@ function renderNode( if (request.status === ABORTING) { // We are aborting so we can just bubble up to the task by falling through + // $FlowFixMe[invalid-compare] } else if (typeof x === 'object' && x !== null) { // $FlowFixMe[method-unbinding] if (typeof x.then === 'function') { @@ -4530,7 +4554,9 @@ function abortTask(task: Task, request: Request, error: mixed): void { node !== null && (isArray(node) || typeof node[ASYNC_ITERATOR] === 'function' || + // $FlowFixMe[invalid-compare] node.$$typeof === REACT_ELEMENT_TYPE || + // $FlowFixMe[invalid-compare] node.$$typeof === REACT_LAZY_TYPE) && isArray(node._debugInfo) ) { @@ -4790,6 +4816,7 @@ function finishedSegment( boundary: Root | SuspenseBoundary, segment: Segment, ) { + // $FlowFixMe[invalid-compare] if (byteLengthOfChunk !== null) { // Count the bytes of all the chunks of this segment. const chunks = segment.chunks; @@ -5126,6 +5153,7 @@ function retryReplayTask(request: Request, task: ReplayTask): void { getSuspendedThenable() : thrownValue; + // $FlowFixMe[invalid-compare] if (typeof x === 'object' && x !== null) { // $FlowFixMe[method-unbinding] if (typeof x.then === 'function') { @@ -5929,6 +5957,7 @@ function flushCompletedQueues( export function startWork(request: Request): void { request.flushScheduled = request.destination !== null; // When prerendering we use microtasks for pinging work + // $FlowFixMe[constant-condition] if (supportsRequestStorage) { scheduleMicrotask(() => requestStorage.run(request, performWork, request)); } else { @@ -5949,6 +5978,7 @@ export function startWork(request: Request): void { // During a prerender we don't want to be too aggressive in emitting early preloads // because we aren't responding to a live request and we can wait for the prerender to // postpone before we emit anything. + // $FlowFixMe[constant-condition] if (supportsRequestStorage) { requestStorage.run( request, diff --git a/packages/react-server/src/ReactFizzViewTransitionComponent.js b/packages/react-server/src/ReactFizzViewTransitionComponent.js index d2e6c0e120f..6ca08ce1783 100644 --- a/packages/react-server/src/ReactFizzViewTransitionComponent.js +++ b/packages/react-server/src/ReactFizzViewTransitionComponent.js @@ -32,10 +32,12 @@ function getClassNameByType(classByType: ?ViewTransitionClass): ?string { } let className: ?string = null; const activeTypes = null; // TODO: Support passing active types. + // $FlowFixMe[constant-condition] if (activeTypes !== null) { for (let i = 0; i < activeTypes.length; i++) { const match = classByType[activeTypes[i]]; if (match != null) { + // $FlowFixMe[invalid-compare] if (match === 'none') { // If anything matches "none" that takes precedence over any other // type that also matches. diff --git a/packages/react-server/src/ReactFlightHooks.js b/packages/react-server/src/ReactFlightHooks.js index ed369be0e9b..0ece88e3b97 100644 --- a/packages/react-server/src/ReactFlightHooks.js +++ b/packages/react-server/src/ReactFlightHooks.js @@ -131,6 +131,7 @@ function useId(): string { function use<T>(usable: Usable<T>): T { if ( + // $FlowFixMe[invalid-compare] (usable !== null && typeof usable === 'object') || typeof usable === 'function' ) { diff --git a/packages/react-server/src/ReactFlightServer.js b/packages/react-server/src/ReactFlightServer.js index 8559473d99e..63ee4de175d 100644 --- a/packages/react-server/src/ReactFlightServer.js +++ b/packages/react-server/src/ReactFlightServer.js @@ -440,6 +440,8 @@ function patchConsole(consoleInst: typeof console, methodName: string) { } } +// $FlowFixMe[constant-condition] +// $FlowFixMe[invalid-compare] if (__DEV__ && typeof console === 'object' && console !== null) { // Instrument console to capture logs for replaying on the client. patchConsole(console, 'assert'); @@ -844,6 +846,7 @@ let currentRequest: null | Request = null; export function resolveRequest(): null | Request { if (currentRequest) return currentRequest; + // $FlowFixMe[constant-condition] if (supportsRequestStorage) { const store = requestStorage.getStore(); if (store) return store; @@ -1763,6 +1766,7 @@ function renderFunctionComponent<Props>( if (request.status === ABORTING) { if ( typeof result === 'object' && + // $FlowFixMe[invalid-compare] result !== null && typeof result.then === 'function' && !isClientReference(result) @@ -3375,6 +3379,7 @@ function renderModel( getSuspendedThenable() : thrownValue; + // $FlowFixMe[invalid-compare] if (typeof x === 'object' && x !== null) { // $FlowFixMe[method-unbinding] if (typeof x.then === 'function') { @@ -3913,6 +3918,7 @@ function renderModelDestructive( return serializeDateFromDateJSON(value); } } + // $FlowFixMe[invalid-compare] if (value.length >= 1024 && byteLengthOfChunk !== null) { // For large strings, we encode them outside the JSON payload so that we // don't have to double encode and double parse the strings. This can also @@ -4057,6 +4063,7 @@ function logRecoverableError( try { const onError = request.onError; if (__DEV__ && task !== null) { + // $FlowFixMe[constant-condition] if (supportsRequestStorage) { errorDigest = requestStorage.run( undefined, @@ -4069,6 +4076,7 @@ function logRecoverableError( } else { errorDigest = callWithDebugContextInDEV(request, task, onError, error); } + // $FlowFixMe[constant-condition] } else if (supportsRequestStorage) { // Exit the request context while running callbacks. errorDigest = requestStorage.run(undefined, onError, error); @@ -4615,6 +4623,7 @@ function emitTextChunk( text: string, debug: boolean, ): void { + // $FlowFixMe[invalid-compare] if (byteLengthOfChunk === null) { // eslint-disable-next-line react-internal/prod-error-codes throw new Error( @@ -5584,6 +5593,7 @@ function emitChunk( const id = task.id; // For certain types we have special types, we typically outlined them but // we can emit them directly for this row instead of through an indirection. + // $FlowFixMe[invalid-compare] if (typeof value === 'string' && byteLengthOfChunk !== null) { if (enableTaint) { const tainted = TaintRegistryValues.get(value); @@ -5802,6 +5812,7 @@ function retryTask(request: Request, task: Task): void { // later, once we deprecate the old API in favor of `use`. getSuspendedThenable() : thrownValue; + // $FlowFixMe[invalid-compare] if (typeof x === 'object' && x !== null) { // $FlowFixMe[method-unbinding] if (typeof x.then === 'function') { @@ -6080,6 +6091,7 @@ function flushCompletedChunks(request: Request): void { export function startWork(request: Request): void { request.flushScheduled = request.destination !== null; + // $FlowFixMe[constant-condition] if (supportsRequestStorage) { scheduleMicrotask(() => { requestStorage.run(request, performWork, request); diff --git a/packages/react/src/ReactAct.js b/packages/react/src/ReactAct.js index c4c8a98d531..c88303c792a 100644 --- a/packages/react/src/ReactAct.js +++ b/packages/react/src/ReactAct.js @@ -103,6 +103,7 @@ export function act<T>(callback: () => T | Thenable<T>): Thenable<T> { } if ( + // $FlowFixMe[invalid-compare] result !== null && typeof result === 'object' && // $FlowFixMe[method-unbinding] diff --git a/packages/react/src/ReactCacheImpl.js b/packages/react/src/ReactCacheImpl.js index d6e0491b6c3..f138fc60a44 100644 --- a/packages/react/src/ReactCacheImpl.js +++ b/packages/react/src/ReactCacheImpl.js @@ -76,6 +76,7 @@ export function cache<A: Iterable<mixed>, T>(fn: (...A) => T): (...A) => T { const arg = arguments[i]; if ( typeof arg === 'function' || + // $FlowFixMe[invalid-compare] (typeof arg === 'object' && arg !== null) ) { // Objects go into a WeakMap diff --git a/packages/react/src/ReactStartTransition.js b/packages/react/src/ReactStartTransition.js index 3e353a3b615..2201618fa55 100644 --- a/packages/react/src/ReactStartTransition.js +++ b/packages/react/src/ReactStartTransition.js @@ -80,6 +80,7 @@ export function startTransition( } if ( typeof returnValue === 'object' && + // $FlowFixMe[invalid-compare] returnValue !== null && typeof returnValue.then === 'function' ) { @@ -94,7 +95,11 @@ export function startTransition( reportGlobalError(error); } finally { warnAboutTransitionSubscriptions(prevTransition, currentTransition); - if (prevTransition !== null && currentTransition.types !== null) { + if ( + prevTransition !== null && + // $FlowFixMe[invalid-compare] + currentTransition.types !== null + ) { // If we created a new types set in the inner transition, we transfer it to the parent // since they should share the same set. They're conceptually entangled. if (__DEV__) { @@ -140,6 +145,7 @@ export function startGestureTransition( if (enableViewTransition) { currentTransition.types = null; } + // $FlowFixMe[constant-condition] if (enableGestureTransition) { currentTransition.gesture = provider; } @@ -158,6 +164,7 @@ export function startGestureTransition( if (__DEV__) { if ( typeof returnValue === 'object' && + // $FlowFixMe[invalid-compare] returnValue !== null && typeof returnValue.then === 'function' ) { diff --git a/packages/react/src/ReactTaint.js b/packages/react/src/ReactTaint.js index 99bf73ac254..d8cb87e2dc5 100644 --- a/packages/react/src/ReactTaint.js +++ b/packages/react/src/ReactTaint.js @@ -63,6 +63,7 @@ export function taintUniqueValue( // eslint-disable-next-line react-internal/safe-string-coercion message = '' + (message || defaultMessage); if ( + // $FlowFixMe[invalid-compare] lifetime === null || (typeof lifetime !== 'object' && typeof lifetime !== 'function') ) { @@ -86,8 +87,12 @@ export function taintUniqueValue( TaintRegistryByteLengths.add(value.byteLength); entryValue = binaryToComparableString(value); } else { + // $FlowFixMe[invalid-compare] const kind = value === null ? 'null' : typeof value; - if (kind === 'object' || kind === 'function') { + if ( + // $FlowFixMe[invalid-compare] + kind === 'object' || kind === 'function' + ) { throw new Error( 'taintUniqueValue cannot taint objects or functions. Try taintObjectReference instead.', ); @@ -127,6 +132,7 @@ export function taintObjectReference( ); } if ( + // $FlowFixMe[invalid-compare] object === null || (typeof object !== 'object' && typeof object !== 'function') ) { diff --git a/packages/scheduler/src/SchedulerProfiling.js b/packages/scheduler/src/SchedulerProfiling.js index b7cc640c34a..7df1d292aa7 100644 --- a/packages/scheduler/src/SchedulerProfiling.js +++ b/packages/scheduler/src/SchedulerProfiling.js @@ -81,6 +81,7 @@ export function markTaskStart( }, ms: number, ) { + // $FlowFixMe[constant-condition] if (enableProfiling) { if (eventLog !== null) { // performance.now returns a float, representing milliseconds. When the @@ -99,6 +100,7 @@ export function markTaskCompleted( }, ms: number, ) { + // $FlowFixMe[constant-condition] if (enableProfiling) { if (eventLog !== null) { logEvent([TaskCompleteEvent, ms * 1000, task.id]); @@ -114,6 +116,7 @@ export function markTaskCanceled( }, ms: number, ) { + // $FlowFixMe[constant-condition] if (enableProfiling) { if (eventLog !== null) { logEvent([TaskCancelEvent, ms * 1000, task.id]); @@ -129,6 +132,7 @@ export function markTaskErrored( }, ms: number, ) { + // $FlowFixMe[constant-condition] if (enableProfiling) { if (eventLog !== null) { logEvent([TaskErrorEvent, ms * 1000, task.id]); @@ -144,6 +148,7 @@ export function markTaskRun( }, ms: number, ) { + // $FlowFixMe[constant-condition] if (enableProfiling) { runIdCounter++; @@ -154,6 +159,7 @@ export function markTaskRun( } export function markTaskYield(task: {id: number, ...}, ms: number) { + // $FlowFixMe[constant-condition] if (enableProfiling) { if (eventLog !== null) { logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]); @@ -162,6 +168,7 @@ export function markTaskYield(task: {id: number, ...}, ms: number) { } export function markSchedulerSuspended(ms: number) { + // $FlowFixMe[constant-condition] if (enableProfiling) { mainThreadIdCounter++; @@ -172,6 +179,7 @@ export function markSchedulerSuspended(ms: number) { } export function markSchedulerUnsuspended(ms: number) { + // $FlowFixMe[constant-condition] if (enableProfiling) { if (eventLog !== null) { logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]); diff --git a/packages/scheduler/src/forks/Scheduler.js b/packages/scheduler/src/forks/Scheduler.js index 8afdb15b2b1..446cf66709b 100644 --- a/packages/scheduler/src/forks/Scheduler.js +++ b/packages/scheduler/src/forks/Scheduler.js @@ -112,6 +112,7 @@ function advanceTimers(currentTime: number) { pop(timerQueue); timer.sortIndex = timer.expirationTime; push(taskQueue, timer); + // $FlowFixMe[constant-condition] if (enableProfiling) { markTaskStart(timer, currentTime); timer.isQueued = true; @@ -142,6 +143,7 @@ function handleTimeout(currentTime: number) { } function flushWork(initialTime: number) { + // $FlowFixMe[constant-condition] if (enableProfiling) { markSchedulerUnsuspended(initialTime); } @@ -157,6 +159,7 @@ function flushWork(initialTime: number) { isPerformingWork = true; const previousPriorityLevel = currentPriorityLevel; try { + // $FlowFixMe[constant-condition] if (enableProfiling) { try { return workLoop(initialTime); @@ -179,6 +182,7 @@ function flushWork(initialTime: number) { currentTask = null; currentPriorityLevel = previousPriorityLevel; isPerformingWork = false; + // $FlowFixMe[constant-condition] if (enableProfiling) { const currentTime = getCurrentTime(); markSchedulerSuspended(currentTime); @@ -206,6 +210,7 @@ function workLoop(initialTime: number) { currentPriorityLevel = currentTask.priorityLevel; // $FlowFixMe[incompatible-use] found when upgrading Flow const didUserCallbackTimeout = currentTask.expirationTime <= currentTime; + // $FlowFixMe[constant-condition] if (enableProfiling) { // $FlowFixMe[incompatible-call] found when upgrading Flow // $FlowFixMe[incompatible-type] @@ -218,6 +223,7 @@ function workLoop(initialTime: number) { // regardless of how much time is left in the current time slice. // $FlowFixMe[incompatible-use] found when upgrading Flow currentTask.callback = continuationCallback; + // $FlowFixMe[constant-condition] if (enableProfiling) { // $FlowFixMe[incompatible-call] found when upgrading Flow // $FlowFixMe[incompatible-type] @@ -226,6 +232,7 @@ function workLoop(initialTime: number) { advanceTimers(currentTime); return true; } else { + // $FlowFixMe[constant-condition] if (enableProfiling) { // $FlowFixMe[incompatible-call] found when upgrading Flow // $FlowFixMe[incompatible-type] @@ -337,6 +344,7 @@ function unstable_scheduleCallback( var currentTime = getCurrentTime(); var startTime; + // $FlowFixMe[invalid-compare] if (typeof options === 'object' && options !== null) { var delay = options.delay; if (typeof delay === 'number' && delay > 0) { @@ -383,6 +391,7 @@ function unstable_scheduleCallback( expirationTime, sortIndex: -1, }; + // $FlowFixMe[constant-condition] if (enableProfiling) { newTask.isQueued = false; } @@ -405,6 +414,7 @@ function unstable_scheduleCallback( } else { newTask.sortIndex = expirationTime; push(taskQueue, newTask); + // $FlowFixMe[constant-condition] if (enableProfiling) { markTaskStart(newTask, currentTime); newTask.isQueued = true; @@ -421,6 +431,7 @@ function unstable_scheduleCallback( } function unstable_cancelCallback(task: Task) { + // $FlowFixMe[constant-condition] if (enableProfiling) { if (task.isQueued) { const currentTime = getCurrentTime(); @@ -465,6 +476,7 @@ function shouldYieldToHost(): boolean { } function requestPaint() { + // $FlowFixMe[constant-condition] if (enableRequestPaint) { needsPaint = true; } @@ -488,6 +500,7 @@ function forceFrameRate(fps: number) { } const performWorkUntilDeadline = () => { + // $FlowFixMe[constant-condition] if (enableRequestPaint) { needsPaint = false; } @@ -595,6 +608,7 @@ export { export const unstable_Profiling: { startLoggingProfilingEvents(): void, stopLoggingProfilingEvents(): ArrayBuffer | null, + // $FlowFixMe[constant-condition] } | null = enableProfiling ? { startLoggingProfilingEvents, diff --git a/packages/scheduler/src/forks/SchedulerMock.js b/packages/scheduler/src/forks/SchedulerMock.js index e478700064f..d34b8069b1a 100644 --- a/packages/scheduler/src/forks/SchedulerMock.js +++ b/packages/scheduler/src/forks/SchedulerMock.js @@ -112,6 +112,7 @@ function advanceTimers(currentTime: number) { pop(timerQueue); timer.sortIndex = timer.expirationTime; push(taskQueue, timer); + // $FlowFixMe[constant-condition] if (enableProfiling) { markTaskStart(timer, currentTime); timer.isQueued = true; @@ -142,6 +143,7 @@ function handleTimeout(currentTime: number) { } function flushWork(hasTimeRemaining: boolean, initialTime: number) { + // $FlowFixMe[constant-condition] if (enableProfiling) { markSchedulerUnsuspended(initialTime); } @@ -157,6 +159,7 @@ function flushWork(hasTimeRemaining: boolean, initialTime: number) { isPerformingWork = true; const previousPriorityLevel = currentPriorityLevel; try { + // $FlowFixMe[constant-condition] if (enableProfiling) { try { return workLoop(hasTimeRemaining, initialTime); @@ -179,6 +182,7 @@ function flushWork(hasTimeRemaining: boolean, initialTime: number) { currentTask = null; currentPriorityLevel = previousPriorityLevel; isPerformingWork = false; + // $FlowFixMe[constant-condition] if (enableProfiling) { const currentTime = getCurrentTime(); markSchedulerSuspended(currentTime); @@ -207,6 +211,7 @@ function workLoop(hasTimeRemaining: boolean, initialTime: number): boolean { currentPriorityLevel = currentTask.priorityLevel; // $FlowFixMe[incompatible-use] found when upgrading Flow const didUserCallbackTimeout = currentTask.expirationTime <= currentTime; + // $FlowFixMe[constant-condition] if (enableProfiling) { // $FlowFixMe[incompatible-call] found when upgrading Flow // $FlowFixMe[incompatible-type] @@ -219,6 +224,7 @@ function workLoop(hasTimeRemaining: boolean, initialTime: number): boolean { // regardless of how much time is left in the current time slice. // $FlowFixMe[incompatible-use] found when upgrading Flow currentTask.callback = continuationCallback; + // $FlowFixMe[constant-condition] if (enableProfiling) { // $FlowFixMe[incompatible-call] found when upgrading Flow // $FlowFixMe[incompatible-type] @@ -235,6 +241,7 @@ function workLoop(hasTimeRemaining: boolean, initialTime: number): boolean { // `toFlushAndYield` and `toFlushAndYieldThrough` testing helpers . } } else { + // $FlowFixMe[constant-condition] if (enableProfiling) { // $FlowFixMe[incompatible-call] found when upgrading Flow // $FlowFixMe[incompatible-type] @@ -340,6 +347,7 @@ function unstable_scheduleCallback( var currentTime = getCurrentTime(); var startTime; + // $FlowFixMe[invalid-compare] if (typeof options === 'object' && options !== null) { var delay = options.delay; if (typeof delay === 'number' && delay > 0) { @@ -381,6 +389,7 @@ function unstable_scheduleCallback( expirationTime, sortIndex: -1, }; + // $FlowFixMe[constant-condition] if (enableProfiling) { newTask.isQueued = false; } @@ -403,6 +412,7 @@ function unstable_scheduleCallback( } else { newTask.sortIndex = expirationTime; push(taskQueue, newTask); + // $FlowFixMe[constant-condition] if (enableProfiling) { markTaskStart(newTask, currentTime); newTask.isQueued = true; @@ -419,6 +429,7 @@ function unstable_scheduleCallback( } function unstable_cancelCallback(task: Task) { + // $FlowFixMe[constant-condition] if (enableProfiling) { if (task.isQueued) { const currentTime = getCurrentTime(); @@ -574,6 +585,7 @@ function unstable_flushAllWithoutAsserting(): boolean { do { hasMoreWork = cb(true, currentMockTime); } while (hasMoreWork); + // $FlowFixMe[constant-condition] if (!hasMoreWork) { scheduledCallback = null; } @@ -677,6 +689,7 @@ export { export const unstable_Profiling: { startLoggingProfilingEvents(): void, stopLoggingProfilingEvents(): ArrayBuffer | null, + // $FlowFixMe[constant-condition] } | null = enableProfiling ? { startLoggingProfilingEvents, diff --git a/packages/scheduler/src/forks/SchedulerPostTask.js b/packages/scheduler/src/forks/SchedulerPostTask.js index 700ff2e5d2c..f79b6721c3b 100644 --- a/packages/scheduler/src/forks/SchedulerPostTask.js +++ b/packages/scheduler/src/forks/SchedulerPostTask.js @@ -96,6 +96,7 @@ export function unstable_scheduleCallback<T>( const controller = new TaskController({priority: postTaskPriority}); const postTaskOptions = { + // $FlowFixMe[invalid-compare] delay: typeof options === 'object' && options !== null ? options.delay : 0, signal: controller.signal, }; diff --git a/yarn.lock b/yarn.lock index 5bffcc53432..99b12653a63 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9222,12 +9222,12 @@ flatted@^3.2.9: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.1.tgz#21db470729a6734d4997002f439cb308987f567a" integrity sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw== -flow-bin@^0.282.0: - version "0.282.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.282.0.tgz#ecbbd0c032c37eb7791eb66a790b9902eab492a6" - integrity sha512-gZnUBsnMN8iYAcvJLEoF04gLaegv93h8IB1e4HURBaPuyUZoBaStAm5z24wl9NviaB66GbN+hZ9vxDSa+HzlzQ== +flow-bin@^0.286.0: + version "0.286.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.286.0.tgz#2fdb61377fb90aedc941beca5172454d85e4114a" + integrity sha512-JXh5vcQqGm5VOevO7o5RJohCito86nDAZ+sFAsXS4G/qisznJlJ2/a+0aC5nyFjQ2r4qkZP3hQ3ZJ4RiNH4cCA== -flow-remove-types@^2.282.0: +flow-remove-types@^2.286.0: version "2.293.0" resolved "https://registry.yarnpkg.com/flow-remove-types/-/flow-remove-types-2.293.0.tgz#ff63c979bbf0da625cc5a9a33af546261ee23307" integrity sha512-UoF3jXBZ3YH1SYSMq+bLchQ7HGOBykPHThCyl7FdWspCzcW1qQ2nVbkbv5fclzLOzlEZ42c8LpeliAC0tqORzA==