From fbb137059e4aacfaab1d36516e9b55050b4a0454 Mon Sep 17 00:00:00 2001 From: Sam Zhou Date: Fri, 5 Jun 2026 13:54:38 -0400 Subject: [PATCH 1/2] [flow] Bump flow to v0.307.1 (#36199) ## Summary Notable changes: - Only $FlowFixMe, $FlowExpectedError suppression comments are supported - All suppression comments need error code - A lot of new invalid-compare and constant-condition errors suppressed. These errors reveal potential logical bugs ## How did you test this change? `yarn flow-ci` --- flow-typed/environments/bom.js | 1 + flow-typed/environments/dom.js | 1 + flow-typed/environments/node.js | 3 + flow-typed/environments/streams.js | 2 +- package.json | 4 +- packages/internal-test-utils/internalAct.js | 4 +- packages/react-cache/src/LRU.js | 1 + .../src/ReactClientConsoleConfigBrowser.js | 5 +- .../src/ReactClientConsoleConfigPlain.js | 5 +- .../src/ReactClientConsoleConfigServer.js | 5 +- .../react-client/src/ReactFlightClient.js | 25 ++++---- .../src/ReactFlightClientStreamConfigNode.js | 1 + .../src/ReactFlightReplyClient.js | 16 +++-- .../react-debug-tools/src/ReactDebugHooks.js | 6 +- packages/react-devtools-core/src/backend.js | 11 +++- .../react-devtools-core/src/standalone.js | 4 +- .../src/background/index.js | 2 +- .../src/main/evalInInspectedWindow.js | 2 + .../src/main/index.js | 1 + packages/react-devtools-shared/src/Logger.js | 1 + .../src/PerformanceLoggingUtils.js | 6 ++ .../src/backend/agent.js | 3 + .../src/backend/fiber/renderer.js | 33 ++++++++-- .../DevToolsFiberInternalReactConstants.js | 16 +++++ .../src/backend/legacy/renderer.js | 4 ++ .../src/backend/utils/formatWithStyles.js | 1 + .../src/backend/utils/index.js | 2 +- .../src/backend/views/TraceUpdates/canvas.js | 2 +- .../src/backend/views/utils.js | 1 + packages/react-devtools-shared/src/bridge.js | 4 +- .../src/devtools/ContextMenu/types.js | 3 +- .../src/devtools/store.js | 18 ++++++ .../src/devtools/views/Components/Element.js | 2 + .../Components/InspectedElementContextTree.js | 3 + .../Components/InspectedElementStateTree.js | 3 + .../src/devtools/views/Components/KeyValue.js | 1 + .../views/Components/OwnersListContext.js | 4 +- .../src/devtools/views/Components/Tree.js | 5 +- .../devtools/views/Components/TreeContext.js | 3 + .../views/Profiler/CommitTreeBuilder.js | 18 ++++++ .../views/Profiler/HookChangeSummary.js | 3 +- .../Profiler/SidebarSelectedFiberInfo.js | 2 + .../src/devtools/views/Profiler/Tooltip.js | 1 + .../views/SuspenseTab/SuspenseBreadcrumbs.js | 1 + .../views/SuspenseTab/SuspenseRects.js | 1 + .../views/SuspenseTab/SuspenseTreeContext.js | 7 ++- .../src/devtools/views/hooks.js | 2 +- .../src/dynamicImportCache.js | 4 ++ packages/react-devtools-shared/src/hook.js | 2 +- .../src/hookNamesCache.js | 4 ++ .../parseHookNames/loadSourceAndMetadata.js | 11 ++++ .../parseHookNames/parseSourceAndMetadata.js | 8 +++ .../src/inspectedElementMutableSource.js | 1 + packages/react-devtools-shared/src/utils.js | 3 +- .../src/app/Iframe/index.js | 2 + .../app/InspectableElements/CustomHooks.js | 4 +- .../react-devtools-shell/src/app/index.js | 2 +- .../react-devtools-timeline/src/CanvasPage.js | 1 + .../src/content-views/SnapshotsView.js | 2 +- .../src/content-views/UserTimingMarksView.js | 1 + .../src/import-worker/preprocessData.js | 2 + .../src/view-base/useCanvasInteraction.js | 2 +- .../src/client/DOMPropertyOperations.js | 2 +- .../src/client/ReactDOMComponent.js | 6 ++ .../src/client/ReactDOMInput.js | 1 + .../src/client/ReactDOMTextarea.js | 2 + .../src/client/ReactFiberConfigDOM.js | 55 ++++++++++------- .../src/client/estimateBandwidth.js | 2 +- .../src/client/validateDOMNesting.js | 1 + .../src/events/DOMPluginEventSystem.js | 2 + .../src/events/ReactDOMEventReplaying.js | 1 + .../src/events/SyntheticEvent.js | 6 +- .../ReactDOMLegacyServerStreamConfig.js | 2 +- .../server/ReactDOMServerExternalRuntime.js | 8 +-- .../src/server/ReactFizzConfigDOM.js | 8 ++- .../react-dom/src/client/ReactDOMClientFB.js | 4 +- .../ReactDOMDefaultTransitionIndicator.js | 12 ++-- packages/react-dom/src/client/ReactDOMRoot.js | 3 + .../react-dom/src/client/ReactDOMRootFB.js | 5 +- .../src/server/ReactDOMFizzServerBrowser.js | 2 + .../src/server/ReactDOMFizzServerBun.js | 3 +- .../src/server/ReactDOMFizzServerEdge.js | 2 + .../src/server/ReactDOMFizzServerNode.js | 2 + .../src/server/ReactDOMFizzStaticBrowser.js | 2 + .../src/server/ReactDOMFizzStaticEdge.js | 2 + .../src/server/ReactDOMFizzStaticNode.js | 2 + packages/react-dom/src/shared/ReactDOM.js | 2 +- .../react-dom/src/shared/ReactDOMFloat.js | 1 + .../react-dom/src/test-utils/FizzTestUtils.js | 2 +- .../src/ReactFlightFBReferences.js | 2 +- .../src/ReactServerStreamConfigFB.js | 2 +- .../ReactFlightClientConfigBundlerFB.js | 6 +- .../src/server/ReactFlightDOMServerNode.js | 6 +- .../react-markup/src/ReactMarkupServer.js | 4 +- .../react-native-renderer/src/ReactFabric.js | 2 + .../src/ReactFabricComponentTree.js | 2 +- .../src/ReactFabricEventEmitter.js | 2 +- .../src/ReactFiberConfigFabric.js | 11 +++- ...eactFiberConfigFabricWithViewTransition.js | 2 +- .../src/ReactNativePublicCompat.js | 12 ++-- .../src/legacy-events/forEachAccumulated.js | 2 +- .../src/ReactNoopFlightClient.js | 9 +-- .../src/ReactNoopFlightServer.js | 7 ++- .../src/ReactNoopServer.js | 13 ++-- .../src/createReactNoop.js | 44 +++++++++++--- .../src/ReactCapturedValue.js | 3 +- .../react-reconciler/src/ReactChildFiber.js | 9 ++- packages/react-reconciler/src/ReactFiber.js | 26 +++++++- .../react-reconciler/src/ReactFiberAct.js | 1 + .../src/ReactFiberApplyGesture.js | 9 +++ .../src/ReactFiberBeginWork.js | 19 ++++++ .../src/ReactFiberClassComponent.js | 9 ++- .../src/ReactFiberClassUpdateQueue.js | 2 + .../src/ReactFiberCommitEffects.js | 11 ++-- .../src/ReactFiberCommitHostEffects.js | 7 +++ .../src/ReactFiberCommitViewTransitions.js | 3 + .../src/ReactFiberCommitWork.js | 38 +++++++++++- .../src/ReactFiberCompleteWork.js | 16 +++++ .../src/ReactFiberConcurrentUpdates.js | 1 + .../src/ReactFiberGestureScheduler.js | 2 + .../react-reconciler/src/ReactFiberHooks.js | 15 +++-- .../src/ReactFiberHostContext.js | 2 + .../src/ReactFiberHydrationContext.js | 32 ++++++++++ .../react-reconciler/src/ReactFiberLane.js | 1 + .../src/ReactFiberNewContext.js | 13 +++- .../src/ReactFiberPerformanceTrack.js | 4 ++ .../src/ReactFiberReconciler.js | 1 + .../src/ReactFiberRootScheduler.js | 1 + .../react-reconciler/src/ReactFiberScope.js | 8 +++ .../src/ReactFiberSuspenseComponent.js | 1 + .../src/ReactFiberSuspenseContext.js | 1 + .../src/ReactFiberThenable.js | 1 + .../src/ReactFiberTracingMarkerComponent.js | 3 + .../src/ReactFiberTransition.js | 4 ++ .../src/ReactFiberWorkLoop.js | 7 ++- .../src/ReactTestSelectors.js | 9 +++ .../src/ReactFlightESMNodeLoader.js | 4 +- .../src/ReactFlightESMReferences.js | 2 +- .../ReactFlightClientConfigBundlerESM.js | 6 +- .../src/server/ReactFlightDOMServerNode.js | 6 +- .../src/ReactDOMServerFB.js | 2 +- .../src/ReactFlightParcelReferences.js | 2 +- .../src/server/ReactFlightDOMServerBrowser.js | 3 + .../src/server/ReactFlightDOMServerEdge.js | 5 +- .../src/server/ReactFlightDOMServerNode.js | 11 ++-- .../src/ReactFlightTurbopackReferences.js | 7 ++- ...ightClientConfigBundlerTurbopackBrowser.js | 6 +- .../src/server/ReactFlightDOMServerBrowser.js | 3 + .../src/server/ReactFlightDOMServerEdge.js | 5 +- .../src/server/ReactFlightDOMServerNode.js | 11 ++-- .../src/ReactFlightUnbundledNodeLoader.js | 4 +- .../src/ReactFlightUnbundledReferences.js | 7 ++- .../src/server/ReactFlightDOMServerNode.js | 11 ++-- .../src/ReactFlightWebpackNodeLoader.js | 4 +- .../src/ReactFlightWebpackReferences.js | 7 ++- ...FlightClientConfigBundlerWebpackBrowser.js | 6 +- .../src/server/ReactFlightDOMServerBrowser.js | 3 + .../src/server/ReactFlightDOMServerEdge.js | 5 +- .../src/server/ReactFlightDOMServerNode.js | 10 +++- .../src/ReactFizzComponentStack.js | 1 + packages/react-server/src/ReactFizzHooks.js | 13 ++-- .../react-server/src/ReactFizzNewContext.js | 7 ++- packages/react-server/src/ReactFizzServer.js | 54 +++++++++++++---- .../react-server/src/ReactFizzThenable.js | 4 +- .../src/ReactFizzViewTransitionComponent.js | 1 + .../src/ReactFlightActionServer.js | 6 +- packages/react-server/src/ReactFlightHooks.js | 1 + .../src/ReactFlightReplyServer.js | 13 ++-- .../react-server/src/ReactFlightServer.js | 60 ++++++++++++------- .../src/ReactFlightServerConfigDebugNode.js | 2 +- .../src/ReactServerConsoleConfigBrowser.js | 2 +- .../src/ReactServerConsoleConfigPlain.js | 2 +- .../src/ReactServerConsoleConfigServer.js | 2 +- .../src/ReactServerStreamConfigBrowser.js | 4 +- .../src/ReactServerStreamConfigBun.js | 8 +-- .../src/ReactServerStreamConfigEdge.js | 2 +- .../src/ReactServerStreamConfigNode.js | 2 +- .../src/ReactSharedInternalsServer.js | 3 +- .../src/flight/ReactFlightCurrentOwner.js | 1 + .../src/ReactTestRenderer.js | 6 +- packages/react/index.development.js | 8 ++- packages/react/index.js | 11 ++-- packages/react/src/ReactAct.js | 1 + packages/react/src/ReactCacheClient.js | 2 +- packages/react/src/ReactCacheImpl.js | 5 +- packages/react/src/ReactChildren.js | 2 +- packages/react/src/ReactLazy.js | 14 +++-- packages/react/src/ReactStartTransition.js | 3 + packages/react/src/ReactTaint.js | 3 + packages/scheduler/src/SchedulerMinHeap.js | 2 +- packages/scheduler/src/SchedulerProfiling.js | 10 +++- packages/scheduler/src/forks/Scheduler.js | 23 +++++-- packages/scheduler/src/forks/SchedulerMock.js | 18 ++++++ .../scheduler/src/forks/SchedulerPostTask.js | 1 + packages/shared/CheckStringCoercion.js | 6 +- scripts/flow/environment.js | 2 +- yarn.lock | 40 ++++++------- 197 files changed, 977 insertions(+), 321 deletions(-) diff --git a/flow-typed/environments/bom.js b/flow-typed/environments/bom.js index 0e83e904cf76..b7c721fb2d20 100644 --- a/flow-typed/environments/bom.js +++ b/flow-typed/environments/bom.js @@ -874,6 +874,7 @@ declare class SharedWorker extends EventTarget { declare function importScripts(...urls: Array): void; declare class WorkerGlobalScope extends EventTarget { + // $FlowFixMe[incompatible-variance] self: this; location: WorkerLocation; navigator: WorkerNavigator; diff --git a/flow-typed/environments/dom.js b/flow-typed/environments/dom.js index 0ea2d2730a06..5a556419d485 100644 --- a/flow-typed/environments/dom.js +++ b/flow-typed/environments/dom.js @@ -1263,6 +1263,7 @@ declare class HTMLCollection<+Elem: Element> { length: number; item(nameOrIndex?: any, optionalIndex?: any): Elem | null; namedItem(name: string): Elem | null; + // $FlowFixMe[incompatible-variance] [index: number | string]: Elem; } diff --git a/flow-typed/environments/node.js b/flow-typed/environments/node.js index a3edff20f893..acf20bcb1a9d 100644 --- a/flow-typed/environments/node.js +++ b/flow-typed/environments/node.js @@ -1908,6 +1908,7 @@ type http$agentOptions = { declare class http$Agent<+SocketT = net$Socket> { constructor(options: http$agentOptions): void; destroy(): void; + // $FlowFixMe[incompatible-variance] freeSockets: {[name: string]: $ReadOnlyArray, ...}; getName(options: { host: string, @@ -1917,7 +1918,9 @@ declare class http$Agent<+SocketT = net$Socket> { }): string; maxFreeSockets: number; maxSockets: number; + // $FlowFixMe[incompatible-variance] requests: {[name: string]: $ReadOnlyArray>, ...}; + // $FlowFixMe[incompatible-variance] sockets: {[name: string]: $ReadOnlyArray, ...}; } diff --git a/flow-typed/environments/streams.js b/flow-typed/environments/streams.js index 17bfae29e612..6a3aa796e68d 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: string): Promise; read(): Promise<{ value: ?any, done: boolean, diff --git a/package.json b/package.json index c67ae862f5de..c247d21d6c0d 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.307.1", + "flow-remove-types": "^2.307.1", "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 c2c4afb21ade..dba6d9f0139d 100644 --- a/packages/internal-test-utils/internalAct.js +++ b/packages/internal-test-utils/internalAct.js @@ -163,7 +163,7 @@ export async function act(scope: () => Thenable): Thenable { throw thrownError; } - // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] return result; } finally { const depth = actingUpdatesScopeDepth; @@ -285,7 +285,7 @@ export async function serverAct(scope: () => Thenable): Thenable { throw thrownError; } - // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] return result; } finally { if (typeof process === 'object') { diff --git a/packages/react-cache/src/LRU.js b/packages/react-cache/src/LRU.js index bf4e4d4c6de8..1ab1c96f9694 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] if (next !== null) { // Entry already cached const resolvedFirst: Entry = (first: any); diff --git a/packages/react-client/src/ReactClientConsoleConfigBrowser.js b/packages/react-client/src/ReactClientConsoleConfigBrowser.js index f67e4afa0c46..3a8625177ea2 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 ee4c87ca6133..3841007b4924 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 6e69ef12a3ce..6663549fbd70 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 f67d99ba71de..e8af45adf713 100644 --- a/packages/react-client/src/ReactFlightClient.js +++ b/packages/react-client/src/ReactFlightClient.js @@ -281,12 +281,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); }; @@ -499,6 +499,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; @@ -722,7 +723,7 @@ function triggerErrorOnChunk( // a stream chunk since any other row shouldn't have more than one entry. const streamChunk: InitializedStreamChunk = (chunk: any); const controller = streamChunk.reason; - // $FlowFixMe[incompatible-call]: The error method should accept mixed. + // $FlowFixMe[incompatible-type]: The error method should accept mixed. controller.error(error); return; } @@ -3294,7 +3295,7 @@ function startReadableStream( } closed = true; if (previousBlockedChunk === null) { - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] controller.error(error); } else { const blockedChunk = previousBlockedChunk; @@ -3526,11 +3527,12 @@ function resolveErrorDev( let error; const errorOptions = // We don't serialize Error.cause in prod so we never need to deserialize + // $FlowFixMe[constant-condition] __DEV__ && 'cause' in errorInfo ? { cause: reviveModel( response, - // $FlowFixMe[incompatible-cast] -- Flow thinks `cause` in `cause?: JSONValue` can be undefined after `in` check. + // $FlowFixMe[incompatible-type] -- Flow thinks `cause` in `cause?: JSONValue` can be undefined after `in` check. (errorInfo.cause: JSONValue), errorInfo, 'cause', @@ -3544,7 +3546,7 @@ function resolveErrorDev( __DEV__ && isAggregateError ? reviveModel( response, - // $FlowFixMe[incompatible-cast] + // $FlowFixMe[incompatible-type] (errorInfo.errors: JSONValue), errorInfo, 'errors', @@ -4059,7 +4061,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; @@ -4411,7 +4413,7 @@ function logComponentInfo( childrenEndTime: number, isLastComponent: boolean, ): void { - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. if ( isLastComponent && root.status === ERRORED && @@ -4590,7 +4592,7 @@ function flushComponentPerformance( if (componentEndTime > childrenEndTime) { childrenEndTime = componentEndTime; } - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. const componentInfo: ReactComponentInfo = candidateInfo; logComponentInfo( response, @@ -4614,7 +4616,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; @@ -4677,7 +4679,7 @@ function flushComponentPerformance( if (componentEndTime > childrenEndTime) { childrenEndTime = componentEndTime; } - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. const componentInfo: ReactComponentInfo = candidateInfo; const env = response._rootEnvironmentName; logComponentAborted( @@ -5323,6 +5325,7 @@ function reviveModel( for (let i = 0; i < value.length; i++) { (value: any)[i] = reviveModel(response, value[i], value, '' + i); } + // $FlowFixMe[invalid-compare] if (value[0] === REACT_ELEMENT_TYPE) { // React element tuple return parseModelTuple(response, value); diff --git a/packages/react-client/src/ReactFlightClientStreamConfigNode.js b/packages/react-client/src/ReactFlightClientStreamConfigNode.js index f544759ccce1..094bc4f94cb6 100644 --- a/packages/react-client/src/ReactFlightClientStreamConfigNode.js +++ b/packages/react-client/src/ReactFlightClientStreamConfigNode.js @@ -21,6 +21,7 @@ export function readPartialStringChunk( decoder: StringDecoder, buffer: Uint8Array, ): string { + // $FlowFixMe[incompatible-type] return decoder.decode(buffer, decoderOptions); } diff --git a/packages/react-client/src/ReactFlightReplyClient.js b/packages/react-client/src/ReactFlightReplyClient.js index 9eaef573be4a..150144c01065 100644 --- a/packages/react-client/src/ReactFlightReplyClient.js +++ b/packages/react-client/src/ReactFlightReplyClient.js @@ -584,7 +584,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? @@ -603,7 +603,7 @@ export function processReply( const prefix = formFieldPrefix + '_' + refId + '_'; // $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); @@ -697,6 +697,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++; @@ -887,7 +888,7 @@ export function processReply( } } modelRoot = model; - // $FlowFixMe[incompatible-return] it's not going to be undefined because we'll encode it. + // $FlowFixMe[incompatible-type] it's not going to be undefined because we'll encode it. return JSON.stringify(model, resolveToJSON); } @@ -913,7 +914,7 @@ export function processReply( // Otherwise, we use FormData to let us stream in the result. formData.set(formFieldPrefix + '0', json); if (pendingParts === 0) { - // $FlowFixMe[incompatible-call] this has already been refined. + // $FlowFixMe[incompatible-type] this has already been refined. resolve(formData); } } @@ -992,7 +993,7 @@ function defaultEncodeFormAction( const prefixedData = new FormData(); // $FlowFixMe[prop-missing] encodedFormData.forEach((value: string | File, key: string) => { - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] prefixedData.append('$ACTION_' + identifierPrefix + ':' + key, value); }); data = prefixedData; @@ -1023,6 +1024,7 @@ function customEncodeFormAction( ); } let boundPromise: Promise> = (referenceClosure.bound: any); + // $FlowFixMe[invalid-compare] if (boundPromise === null) { boundPromise = Promise.resolve([]); } @@ -1202,6 +1204,7 @@ export function registerBoundServerReference( // Expose encoder for use by SSR, as well as a special bind that can be used to // keep server capabilities. + // $FlowFixMe[constant-condition] if (usedWithSSR) { // Only expose this in builds that would actually use it. Not needed in the browser. const $$FORM_ACTION = @@ -1242,7 +1245,7 @@ function bind(this: Function): Function { const referenceClosure = knownServerReferences.get(this); if (!referenceClosure) { - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] return FunctionBind.apply(this, arguments); } @@ -1278,6 +1281,7 @@ function bind(this: Function): Function { // Expose encoder for use by SSR, as well as a special bind that can be used to // keep server capabilities. + // $FlowFixMe[constant-condition] if (usedWithSSR) { // Only expose this in builds that would actually use it. Not needed on the client. Object.defineProperties((newFn: any), { diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js index b4eb6c2b5965..c288b7851f58 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') { @@ -729,8 +730,9 @@ function useActionState( function useHostTransitionStatus(): TransitionStatus { const status = readContext( // $FlowFixMe[prop-missing] `readContext` only needs _currentValue + // $FlowFixMe[incompatible-type] ({ - // $FlowFixMe[incompatible-cast] TODO: Incorrect bottom value without access to Fiber config. + // $FlowFixMe[incompatible-type] TODO: Incorrect bottom value without access to Fiber config. _currentValue: null, }: ReactContext), ); @@ -1341,10 +1343,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-devtools-core/src/backend.js b/packages/react-devtools-core/src/backend.js index 075758f78500..5e70a178bace 100644 --- a/packages/react-devtools-core/src/backend.js +++ b/packages/react-devtools-core/src/backend.js @@ -51,6 +51,7 @@ let savedComponentFilters: Array = getDefaultComponentFilters(); function debug(methodName: string, ...args: Array) { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( `%c[core/backend] %c${methodName}`, @@ -154,12 +155,14 @@ export function connectToDevTools(options: ?ConnectOptions) { }, send(event: string, payload: any, transferable?: Array) { if (ws.readyState === ws.OPEN) { + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('wall.send()', event, payload); } ws.send(JSON.stringify({event, payload})); } else { + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug( 'wall.send()', @@ -186,7 +189,7 @@ export function connectToDevTools(options: ?ConnectOptions) { ); // TODO (npm-packages) Warn if "isBackendStorageAPISupported" - // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] found when upgrading Flow const agent = new Agent(bridge, isProfiling, onReloadAndProfile); if (typeof onReloadAndProfileFlagsReset === 'function') { onReloadAndProfileFlagsReset(); @@ -210,9 +213,10 @@ export function connectToDevTools(options: ?ConnectOptions) { // Setup React Native style editor if the environment supports it. if (resolveRNStyle != null || hook.resolveRNStyle != null) { setupNativeStyleEditor( - // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] found when upgrading Flow bridge, agent, + // $FlowFixMe[constant-condition] ((resolveRNStyle || hook.resolveRNStyle: any): ResolveNativeStyle), nativeStyleEditorValidAttributes || hook.nativeStyleEditorValidAttributes || @@ -272,6 +276,7 @@ export function connectToDevTools(options: ?ConnectOptions) { }; function handleClose() { + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('WebSocket.onclose'); } @@ -284,6 +289,7 @@ export function connectToDevTools(options: ?ConnectOptions) { } function handleFailed() { + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('WebSocket.onerror'); } @@ -296,6 +302,7 @@ export function connectToDevTools(options: ?ConnectOptions) { try { if (typeof event.data === 'string') { data = JSON.parse(event.data); + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('WebSocket.onmessage', data); } diff --git a/packages/react-devtools-core/src/standalone.js b/packages/react-devtools-core/src/standalone.js index 81f357751913..6d32f18c4851 100644 --- a/packages/react-devtools-core/src/standalone.js +++ b/packages/react-devtools-core/src/standalone.js @@ -83,6 +83,7 @@ log.error = (...args: Array) => console.error('[React DevTools]', ...args); function debug(methodName: string, ...args: Array) { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( `%c[core/standalone] %c${methodName}`, @@ -225,6 +226,7 @@ function initialize(socket: WebSocket) { if (typeof event.data === 'string') { data = JSON.parse(event.data); + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('WebSocket.onmessage', data); } @@ -265,7 +267,7 @@ function initialize(socket: WebSocket) { socket.close(); }); - // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] found when upgrading Flow store = new Store(bridge, { checkBridgeProtocolCompatibility: true, supportsTraceUpdates: true, diff --git a/packages/react-devtools-extensions/src/background/index.js b/packages/react-devtools-extensions/src/background/index.js index 0ed719c20b22..34c337a59e25 100644 --- a/packages/react-devtools-extensions/src/background/index.js +++ b/packages/react-devtools-extensions/src/background/index.js @@ -94,7 +94,7 @@ chrome.runtime.onConnect.addListener(port => { registerTab(tabId); registerProxyPort( port, - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] tabId, ); diff --git a/packages/react-devtools-extensions/src/main/evalInInspectedWindow.js b/packages/react-devtools-extensions/src/main/evalInInspectedWindow.js index 27a339f4e8ae..073224b511b5 100644 --- a/packages/react-devtools-extensions/src/main/evalInInspectedWindow.js +++ b/packages/react-devtools-extensions/src/main/evalInInspectedWindow.js @@ -50,6 +50,7 @@ function fallbackEvalInInspectedWindow( }); const timeout = setTimeout(() => { evalRequestCallbacks.delete(requestId); + // $FlowFixMe[constant-condition] if (callback) { callback(null, { code, @@ -64,6 +65,7 @@ function fallbackEvalInInspectedWindow( evalRequestCallbacks.set(requestId, ({result, error}) => { clearTimeout(timeout); evalRequestCallbacks.delete(requestId); + // $FlowFixMe[constant-condition] if (callback) { if (error) { callback(null, { diff --git a/packages/react-devtools-extensions/src/main/index.js b/packages/react-devtools-extensions/src/main/index.js index 0072b6934585..5954460edb68 100644 --- a/packages/react-devtools-extensions/src/main/index.js +++ b/packages/react-devtools-extensions/src/main/index.js @@ -453,6 +453,7 @@ function performInTabNavigationCleanup() { // Potentially, if react hasn't loaded yet and user performs in-tab navigation clearReactPollingInstance(); + // $FlowFixMe[invalid-compare] if (store !== null) { // Store profiling data, so it can be used later profilingData = store.profilerStore.profilingData; diff --git a/packages/react-devtools-shared/src/Logger.js b/packages/react-devtools-shared/src/Logger.js index 0d1324d0d70a..bd6a47d206e0 100644 --- a/packages/react-devtools-shared/src/Logger.js +++ b/packages/react-devtools-shared/src/Logger.js @@ -84,6 +84,7 @@ export const logEvent: LogFunction = export const registerEventLogger: (logFunction: LogFunction) => () => void = enableLogger === true ? function registerEventLogger(logFunction: LogFunction): () => void { + // $FlowFixMe[constant-condition] if (enableLogger) { logFunctions.push(logFunction); return function unregisterEventLogger() { diff --git a/packages/react-devtools-shared/src/PerformanceLoggingUtils.js b/packages/react-devtools-shared/src/PerformanceLoggingUtils.js index 68741a899261..991064997cc7 100644 --- a/packages/react-devtools-shared/src/PerformanceLoggingUtils.js +++ b/packages/react-devtools-shared/src/PerformanceLoggingUtils.js @@ -48,11 +48,13 @@ export async function withAsyncPerfMeasurements( onComplete?: number => void, ): Promise { const start = now(); + // $FlowFixMe[constant-condition] if (__PERFORMANCE_PROFILE__) { mark(markName); } const result = await callback(); + // $FlowFixMe[constant-condition] if (__PERFORMANCE_PROFILE__) { measure(markName); } @@ -71,11 +73,13 @@ export function withSyncPerfMeasurements( onComplete?: number => void, ): TReturn { const start = now(); + // $FlowFixMe[constant-condition] if (__PERFORMANCE_PROFILE__) { mark(markName); } const result = callback(); + // $FlowFixMe[constant-condition] if (__PERFORMANCE_PROFILE__) { measure(markName); } @@ -94,11 +98,13 @@ export function withCallbackPerfMeasurements( onComplete?: number => void, ): TReturn { const start = now(); + // $FlowFixMe[constant-condition] if (__PERFORMANCE_PROFILE__) { mark(markName); } const done = () => { + // $FlowFixMe[constant-condition] if (__PERFORMANCE_PROFILE__) { measure(markName); } diff --git a/packages/react-devtools-shared/src/backend/agent.js b/packages/react-devtools-shared/src/backend/agent.js index 18f3e208408b..73fb202ad4e0 100644 --- a/packages/react-devtools-shared/src/backend/agent.js +++ b/packages/react-devtools-shared/src/backend/agent.js @@ -46,6 +46,7 @@ import { } from '../storage'; const debug = (methodName: string, ...args: Array) => { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( `%cAgent %c${methodName}`, @@ -1110,6 +1111,7 @@ export default class Agent extends EventEmitter<{ }; onFastRefreshScheduled: () => void = () => { + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('onFastRefreshScheduled'); } @@ -1118,6 +1120,7 @@ export default class Agent extends EventEmitter<{ }; onHookOperations: (operations: Array) => void = operations => { + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug( 'onHookOperations', diff --git a/packages/react-devtools-shared/src/backend/fiber/renderer.js b/packages/react-devtools-shared/src/backend/fiber/renderer.js index 037ce1c5cc3b..bbc38d341a29 100644 --- a/packages/react-devtools-shared/src/backend/fiber/renderer.js +++ b/packages/react-devtools-shared/src/backend/fiber/renderer.js @@ -765,6 +765,7 @@ export function attach( parentInstance: null | DevToolsInstance, extraString: string = '', ): void { + // $FlowFixMe[constant-condition] if (__DEBUG__) { const displayName = instance.kind === VIRTUAL_INSTANCE @@ -807,6 +808,7 @@ export function attach( // eslint-disable-next-line no-unused-vars function debugTree(instance: DevToolsInstance, indent: number = 0) { + // $FlowFixMe[constant-condition] if (__DEBUG__) { const name = (instance.kind !== VIRTUAL_INSTANCE @@ -1768,6 +1770,7 @@ export function attach( } idToDevToolsInstanceMap.set(fiberInstance.id, fiberInstance); + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('recordMount()', fiberInstance, parentInstance); } @@ -2078,6 +2081,7 @@ export function attach( const isSuspended = fiber.tag === SuspenseComponent && fiber.memoizedState !== null; + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log('recordSuspenseMount()', suspenseInstance); } @@ -2106,6 +2110,7 @@ export function attach( } function recordUnmount(fiberInstance: FiberInstance): void { + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('recordUnmount()', fiberInstance, reconcilingParent); } @@ -2140,6 +2145,7 @@ export function attach( } function recordSuspenseResize(suspenseNode: SuspenseNode): void { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log('recordSuspenseResize()', suspenseNode); } @@ -2167,6 +2173,7 @@ export function attach( } function recordSuspenseSuspenders(suspenseNode: SuspenseNode): void { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log('recordSuspenseSuspenders()', suspenseNode); } @@ -2187,6 +2194,7 @@ export function attach( } function recordSuspenseUnmount(suspenseInstance: SuspenseNode): void { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( 'recordSuspenseUnmount()', @@ -2335,6 +2343,7 @@ export function attach( return; } let node: SuspenseNode = firstChild; + // $FlowFixMe[invalid-compare] while (node !== null) { if (node.suspendedBy.has(ioInfo)) { // We have found a child boundary that depended on the unblocked I/O. @@ -2993,7 +3002,7 @@ export function attach( start, end, value: promise, - // $FlowFixMe: This field doesn't usually take a Fiber but we're only using inside this file. + // $FlowFixMe[incompatible-type]: This field doesn't usually take a Fiber but we're only using inside this file. owner: fiber, // Allow linking to the if it's not filtered. }; if (byteSize > 0) { @@ -3002,7 +3011,7 @@ export function attach( } const asyncInfo: ReactAsyncInfo = { awaited: ioInfo, - // $FlowFixMe: This field doesn't usually take a Fiber but we're only using inside this file. + // $FlowFixMe[incompatible-type]: This field doesn't usually take a Fiber but we're only using inside this file. owner: fiber._debugOwner == null ? null : fiber._debugOwner, debugStack: fiber._debugStack == null ? null : fiber._debugStack, debugTask: fiber._debugTask == null ? null : fiber._debugTask, @@ -3109,7 +3118,7 @@ export function attach( start, end, value: promise, - // $FlowFixMe: This field doesn't usually take a Fiber but we're only using inside this file. + // $FlowFixMe[incompatible-type]: This field doesn't usually take a Fiber but we're only using inside this file. owner: fiber, // Allow linking to the if it's not filtered. }; if (byteSize > 0) { @@ -3118,7 +3127,7 @@ export function attach( } const asyncInfo: ReactAsyncInfo = { awaited: ioInfo, - // $FlowFixMe: This field doesn't usually take a Fiber but we're only using inside this file. + // $FlowFixMe[incompatible-type]: This field doesn't usually take a Fiber but we're only using inside this file. owner: fiber._debugOwner == null ? null : fiber._debugOwner, debugStack: fiber._debugStack == null ? null : fiber._debugStack, debugTask: fiber._debugTask == null ? null : fiber._debugTask, @@ -3360,6 +3369,7 @@ export function attach( recordSuspenseMount(newSuspenseNode, reconcilingParentSuspenseNode); } insertChild(newInstance); + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('mountFiberRecursively()', newInstance, reconcilingParent); } @@ -3420,6 +3430,7 @@ export function attach( } } insertChild(newInstance); + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('mountFiberRecursively()', newInstance, reconcilingParent); } @@ -3620,6 +3631,7 @@ export function attach( // We use this to simulate unmounting for Suspense trees // when we switch from primary to fallback, or deleting a subtree. function unmountInstanceRecursively(instance: DevToolsInstance) { + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('unmountInstanceRecursively()', instance, reconcilingParent); } @@ -3655,6 +3667,7 @@ export function attach( isInFocusedActivity = true; } else if ( instance.kind === FIBER_INSTANCE && + // $FlowFixMe[invalid-compare] instance.data !== null && instance.data.tag === ActivityComponent ) { @@ -3871,6 +3884,7 @@ export function attach( function recordResetChildren( parentInstance: FiberInstance | VirtualInstance, ) { + // $FlowFixMe[constant-condition] if (__DEBUG__) { if (parentInstance.firstChild !== null) { debug( @@ -3916,6 +3930,7 @@ export function attach( } function recordResetSuspenseChildren(parentInstance: SuspenseNode) { + // $FlowFixMe[constant-condition] if (__DEBUG__) { if (parentInstance.firstChild !== null) { console.log( @@ -3939,6 +3954,7 @@ export function attach( } pushOperation(SUSPENSE_TREE_OPERATION_REORDER_CHILDREN); // $FlowFixMe[incompatible-call] TODO: Allow filtering SuspenseNode + // $FlowFixMe[incompatible-type] pushOperation(parentInstance.instance.id); pushOperation(numChildren); for (let i = 0; i < nextChildren.length; i++) { @@ -4365,6 +4381,7 @@ export function attach( prevFiber: Fiber, traceNearestHostComponentUpdate: boolean, ): UpdateFlags { + // $FlowFixMe[constant-condition] if (__DEBUG__) { if (fiberInstance !== null) { debug('updateFiberRecursively()', fiberInstance, reconcilingParent); @@ -5341,7 +5358,7 @@ export function attach( function getNearestMountedDOMNode(publicInstance: Element): null | Element { let domNode: null | Element = publicInstance; while (domNode && !publicInstanceToDevToolsInstanceMap.has(domNode)) { - // $FlowFixMe: In practice this is either null or Element. + // $FlowFixMe[incompatible-type]: In practice this is either null or Element. domNode = domNode.parentNode; } return domNode; @@ -6045,6 +6062,7 @@ export function attach( } const fiber = devtoolsInstance.data; + // $FlowFixMe[invalid-compare] if (fiber !== null) { instance = fiber.stateNode; @@ -7025,6 +7043,7 @@ export function attach( return; } const fiber = devtoolsInstance.data; + // $FlowFixMe[invalid-compare] if (fiber !== null) { const instance = fiber.stateNode; @@ -7095,6 +7114,7 @@ export function attach( return; } const fiber = devtoolsInstance.data; + // $FlowFixMe[invalid-compare] if (fiber !== null) { const instance = fiber.stateNode; @@ -7178,6 +7198,7 @@ export function attach( return; } const fiber = devtoolsInstance.data; + // $FlowFixMe[invalid-compare] if (fiber !== null) { const instance = fiber.stateNode; @@ -8102,7 +8123,7 @@ export function attach( return (instance.source = extractLocationFromComponentStack(lastLine)); } - // $FlowFixMe: refined. + // $FlowFixMe[incompatible-type]: refined. return unresolvedSource; } diff --git a/packages/react-devtools-shared/src/backend/fiber/shared/DevToolsFiberInternalReactConstants.js b/packages/react-devtools-shared/src/backend/fiber/shared/DevToolsFiberInternalReactConstants.js index 2f7f92eefbfd..053c519c887c 100644 --- a/packages/react-devtools-shared/src/backend/fiber/shared/DevToolsFiberInternalReactConstants.js +++ b/packages/react-devtools-shared/src/backend/fiber/shared/DevToolsFiberInternalReactConstants.js @@ -385,12 +385,16 @@ export function getInternalReactConstants(version: string): { } switch (tag) { + // $FlowFixMe[invalid-compare] case ActivityComponent: return 'Activity'; + // $FlowFixMe[invalid-compare] case CacheComponent: return 'Cache'; case ClassComponent: + // $FlowFixMe[invalid-compare] -- falls through case IncompleteClassComponent: + // $FlowFixMe[invalid-compare] -- falls through case IncompleteFunctionComponent: case FunctionComponent: case IndeterminateComponent: @@ -409,7 +413,9 @@ export function getInternalReactConstants(version: string): { } return null; case HostComponent: + // $FlowFixMe[invalid-compare] -- falls through case HostSingleton: + // $FlowFixMe[invalid-compare] -- falls through case HostHoistable: return type; case HostPortal: @@ -417,12 +423,15 @@ export function getInternalReactConstants(version: string): { return null; case Fragment: return 'Fragment'; + // $FlowFixMe[invalid-compare] case LazyComponent: // This display name will not be user visible. // Once a Lazy component loads its inner component, React replaces the tag and type. // This display name will only show up in console logs when DevTools DEBUG mode is on. return 'Lazy'; + // $FlowFixMe[invalid-compare] case MemoComponent: + // $FlowFixMe[invalid-compare] -- falls through case SimpleMemoComponent: // Display name in React does not use `Memo` as a wrapper but fallback name. return getWrappedDisplayName( @@ -433,20 +442,27 @@ export function getInternalReactConstants(version: string): { ); case SuspenseComponent: return 'Suspense'; + // $FlowFixMe[invalid-compare] case LegacyHiddenComponent: return 'LegacyHidden'; + // $FlowFixMe[invalid-compare] case OffscreenComponent: return 'Offscreen'; + // $FlowFixMe[invalid-compare] case ScopeComponent: return 'Scope'; + // $FlowFixMe[invalid-compare] case SuspenseListComponent: return 'SuspenseList'; case Profiler: return 'Profiler'; + // $FlowFixMe[invalid-compare] case TracingMarkerComponent: return 'TracingMarker'; + // $FlowFixMe[invalid-compare] case ViewTransitionComponent: return 'ViewTransition'; + // $FlowFixMe[invalid-compare] case Throw: // This should really never be visible. return 'Error'; diff --git a/packages/react-devtools-shared/src/backend/legacy/renderer.js b/packages/react-devtools-shared/src/backend/legacy/renderer.js index ccd9cdac3e02..a908c727b182 100644 --- a/packages/react-devtools-shared/src/backend/legacy/renderer.js +++ b/packages/react-devtools-shared/src/backend/legacy/renderer.js @@ -390,6 +390,7 @@ export function attach( ) { const isRoot = parentID === 0; + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( '%crecordMount()', @@ -472,6 +473,7 @@ export function attach( parentID: number, rootID: number, ) { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.group('crawlAndRecordInitialMounts() id:', id); } @@ -485,6 +487,7 @@ export function attach( ); } + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.groupEnd(); } @@ -584,6 +587,7 @@ export function attach( } i += pendingOperations.length; + // $FlowFixMe[constant-condition] if (__DEBUG__) { printOperationsArray(operations); } diff --git a/packages/react-devtools-shared/src/backend/utils/formatWithStyles.js b/packages/react-devtools-shared/src/backend/utils/formatWithStyles.js index b258141e353f..6d92b7dad583 100644 --- a/packages/react-devtools-shared/src/backend/utils/formatWithStyles.js +++ b/packages/react-devtools-shared/src/backend/utils/formatWithStyles.js @@ -32,6 +32,7 @@ export default function formatWithStyles( ): $ReadOnlyArray { if ( inputArgs === undefined || + // $FlowFixMe[invalid-compare] inputArgs === null || inputArgs.length === 0 || // Matches any of %c but not %%c diff --git a/packages/react-devtools-shared/src/backend/utils/index.js b/packages/react-devtools-shared/src/backend/utils/index.js index fcb8d448a0c1..e9a8677000a0 100644 --- a/packages/react-devtools-shared/src/backend/utils/index.js +++ b/packages/react-devtools-shared/src/backend/utils/index.js @@ -195,7 +195,7 @@ export function formatConsoleArgumentsToSingleString( if (args.length) { const REGEXP = /(%?)(%([jds]))/g; - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] formatted = formatted.replace(REGEXP, (match, escaped, ptn, flag) => { let arg = args.shift(); switch (flag) { diff --git a/packages/react-devtools-shared/src/backend/views/TraceUpdates/canvas.js b/packages/react-devtools-shared/src/backend/views/TraceUpdates/canvas.js index b9e2cd906813..6c7383183d06 100644 --- a/packages/react-devtools-shared/src/backend/views/TraceUpdates/canvas.js +++ b/packages/react-devtools-shared/src/backend/views/TraceUpdates/canvas.js @@ -217,7 +217,7 @@ function destroyWeb() { // $FlowFixMe[incompatible-use]: Flow doesn't recognize Popover API and loses canvas nullability tracking if (canvas.parentNode != null) { - // $FlowFixMe[incompatible-call]: Flow doesn't track that canvas is non-null here + // $FlowFixMe[incompatible-type]: Flow doesn't track that canvas is non-null here canvas.parentNode.removeChild(canvas); } canvas = null; diff --git a/packages/react-devtools-shared/src/backend/views/utils.js b/packages/react-devtools-shared/src/backend/views/utils.js index a73c8094edb9..55c5a2f14eb3 100644 --- a/packages/react-devtools-shared/src/backend/views/utils.js +++ b/packages/react-devtools-shared/src/backend/views/utils.js @@ -104,6 +104,7 @@ export function getNestedBoundingClientRect( } // $FlowFixMe[incompatible-variance] + // $FlowFixMe[incompatible-type] return mergeRectOffsets(rects); } else { // $FlowFixMe[incompatible-variance] diff --git a/packages/react-devtools-shared/src/bridge.js b/packages/react-devtools-shared/src/bridge.js index ba4b2a0f8061..4ad87cceac4c 100644 --- a/packages/react-devtools-shared/src/bridge.js +++ b/packages/react-devtools-shared/src/bridge.js @@ -361,13 +361,13 @@ class Bridge< this._messageQueue.push(event, payload); if (!this._scheduledFlush) { this._scheduledFlush = true; - // $FlowFixMe + // $FlowFixMe[cannot-resolve-name] if (typeof devtoolsJestTestScheduler === 'function') { // This exists just for our own jest tests. // They're written in such a way that we can neither mock queueMicrotask // because then we break React DOM and we can't not mock it because then // we can't synchronously flush it. So they need to be rewritten. - // $FlowFixMe + // $FlowFixMe[cannot-resolve-name] devtoolsJestTestScheduler(this._flush); // eslint-disable-line no-undef } else { queueMicrotask(this._flush); diff --git a/packages/react-devtools-shared/src/devtools/ContextMenu/types.js b/packages/react-devtools-shared/src/devtools/ContextMenu/types.js index 9fda9be19994..6395383bf83f 100644 --- a/packages/react-devtools-shared/src/devtools/ContextMenu/types.js +++ b/packages/react-devtools-shared/src/devtools/ContextMenu/types.js @@ -26,6 +26,7 @@ export type ContextMenuHandle = { }; export type ContextMenuComponent = component( - ref: React$RefSetter, + // eslint-disable-next-line no-undef + ref: React.RefSetter, ); export type ContextMenuRef = {current: ContextMenuHandle | null}; diff --git a/packages/react-devtools-shared/src/devtools/store.js b/packages/react-devtools-shared/src/devtools/store.js index e11b90272e59..9fbb3beaab10 100644 --- a/packages/react-devtools-shared/src/devtools/store.js +++ b/packages/react-devtools-shared/src/devtools/store.js @@ -96,6 +96,7 @@ class RectRBush extends RBush { } const debug = (methodName: string, ...args: Array) => { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( `%cStore %c${methodName}`, @@ -273,6 +274,7 @@ export default class Store extends EventEmitter<{ constructor(bridge: FrontendBridge, config?: Config) { super(); + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('constructor', 'subscribing to Bridge'); } @@ -1055,6 +1057,7 @@ export default class Store extends EventEmitter<{ ): Array { const target: Array = []; const focusedTransitionID = this._focusedTransition; + // $FlowFixMe[invalid-compare] if (focusedTransitionID === null) { return target; } @@ -1373,6 +1376,7 @@ export default class Store extends EventEmitter<{ }; onBridgeOperations: (operations: Array) => void = operations => { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.groupCollapsed('onBridgeOperations'); debug('onBridgeOperations', operations.join(',')); @@ -1435,6 +1439,7 @@ export default class Store extends EventEmitter<{ } if (type === ElementTypeRoot) { + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('Add', `new root node ${id}`); } @@ -1526,6 +1531,7 @@ export default class Store extends EventEmitter<{ const nameProp = stringTable[namePropStringID]; i++; + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug( 'Add', @@ -1633,6 +1639,7 @@ export default class Store extends EventEmitter<{ let parentElement: ?Element = null; if (parentID === 0) { + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('Remove', `node ${id} root`); } @@ -1643,6 +1650,7 @@ export default class Store extends EventEmitter<{ haveRootsChanged = true; } else { + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('Remove', `node ${id} from parent ${parentID}`); } @@ -1721,6 +1729,7 @@ export default class Store extends EventEmitter<{ } i += numChildren; + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('Re-order', `Node ${id} children ${children.join(',')}`); } @@ -1776,6 +1785,7 @@ export default class Store extends EventEmitter<{ } } + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug( 'Subtree mode', @@ -1858,6 +1868,7 @@ export default class Store extends EventEmitter<{ } } + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('Suspense Add', `node ${id} as child of ${parentID}`); } @@ -1931,10 +1942,12 @@ export default class Store extends EventEmitter<{ let parentSuspense: ?SuspenseNode = null; if (parentID === 0) { + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('Suspense remove', `node ${id} root`); } } else { + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('Suspense Remove', `node ${id} from parent ${parentID}`); } @@ -2005,6 +2018,7 @@ export default class Store extends EventEmitter<{ } i += numChildren; + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug( 'Re-order', @@ -2063,6 +2077,7 @@ export default class Store extends EventEmitter<{ suspense.rects = nextRects; + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug( 'Resize', @@ -2117,6 +2132,7 @@ export default class Store extends EventEmitter<{ break; } + // $FlowFixMe[constant-condition] if (__DEBUG__) { const previousHasUniqueSuspenders = suspense.hasUniqueSuspenders; debug( @@ -2235,6 +2251,7 @@ export default class Store extends EventEmitter<{ this.emit('suspenseTreeMutated', [removedSuspenseIDs]); } + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log(printStore(this, true)); console.groupEnd(); @@ -2319,6 +2336,7 @@ export default class Store extends EventEmitter<{ } onBridgeShutdown: () => void = () => { + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('onBridgeShutdown', 'unsubscribing from Bridge'); } diff --git a/packages/react-devtools-shared/src/devtools/views/Components/Element.js b/packages/react-devtools-shared/src/devtools/views/Components/Element.js index da71f86dd797..284640364cb9 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/Element.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/Element.js @@ -89,6 +89,7 @@ export default function Element({data, index, style}: Props): React.Node { // $FlowFixMe[missing-local-annot] const handleClick = ({metaKey, button}) => { + // $FlowFixMe[invalid-compare] if (id !== null && button === 0) { logEvent({ event_name: 'select-element', @@ -103,6 +104,7 @@ export default function Element({data, index, style}: Props): React.Node { const handleMouseEnter = () => { setIsHovered(true); + // $FlowFixMe[invalid-compare] if (id !== null) { onElementMouseEnter(id); } diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContextTree.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContextTree.js index 941fa5fe01dd..ac0b8a6a7739 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContextTree.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContextTree.js @@ -70,13 +70,16 @@ export default function InspectedElementContextTree({
{hasLegacyContext ? 'legacy context' : 'context'}
+ {/* $FlowFixMe[constant-condition] */} {!isEmpty && ( )} + {/* $FlowFixMe[constant-condition] */} {isEmpty &&
None
} + {/* $FlowFixMe[constant-condition] */} {!isEmpty && (entries: any).map(([name, value]) => (
state
+ {/* $FlowFixMe[constant-condition] */} {!isEmpty && ( )}
+ {/* $FlowFixMe[constant-condition] */} {isEmpty &&
None
} + {/* $FlowFixMe[constant-condition] */} {!isEmpty && (entries: any).map(([name, value]) => ( void { resolveFn = resolve; }); - // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] found when upgrading Flow inProgressRequests.set(element, {promise, resolveFn}); } diff --git a/packages/react-devtools-shared/src/devtools/views/Components/Tree.js b/packages/react-devtools-shared/src/devtools/views/Components/Tree.js index 502056f936c8..5e79d0478bc5 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/Tree.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/Tree.js @@ -132,7 +132,7 @@ export default function Tree(): React.Node { Math.min(0, elementLeft - viewportLeft) + Math.max(0, elementRight - viewportRight); - // $FlowExpectedError[incompatible-call] Flow doesn't support instant as an option for behavior. + // $FlowExpectedError[incompatible-type] Flow doesn't support instant as an option for behavior. listDOMElement.scrollBy({ left: horizontalDelta, behavior: 'instant', @@ -181,7 +181,7 @@ export default function Tree(): React.Node { Math.min(0, elementLeft - viewportLeft) + Math.max(0, elementRight - viewportRight); - // $FlowExpectedError[incompatible-call] Flow doesn't support instant as an option for behavior. + // $FlowExpectedError[incompatible-type] Flow doesn't support instant as an option for behavior. listDOMElement.scrollBy({ top: verticalDelta, left: horizontalDelta, @@ -237,6 +237,7 @@ export default function Tree(): React.Node { : null; if (element !== null) { if (event.altKey) { + // $FlowFixMe[invalid-compare] if (element.ownerID !== null) { dispatch({type: 'SELECT_OWNER_LIST_PREVIOUS_ELEMENT_IN_TREE'}); } diff --git a/packages/react-devtools-shared/src/devtools/views/Components/TreeContext.js b/packages/react-devtools-shared/src/devtools/views/Components/TreeContext.js index 80b1e9dce3e3..58e86054d9ec 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/TreeContext.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/TreeContext.js @@ -552,6 +552,7 @@ function reduceSearchState(store: Store, state: State, action: Action): State { // It's possible that multiple tree operations will fire before this action has run. // So it's important to check for elements that may have been added and then removed. + // $FlowFixMe[invalid-compare] if (element !== null) { const {displayName} = element; @@ -624,6 +625,7 @@ function reduceSearchState(store: Store, state: State, action: Action): State { } if (searchText !== prevSearchText) { + // $FlowFixMe[incompatible-type] const newSearchIndex = searchResults.indexOf(inspectedElementID); if (newSearchIndex === -1) { // Only move the selection if the new query @@ -721,6 +723,7 @@ function reduceOwnersState(store: Store, state: State, action: Action): State { // If the selected element is outside of the current owners list, // exit the list and select the element in the main tree. // This supports features like toggling Suspense. + // $FlowFixMe[invalid-compare] if (inspectedElementIndex !== null && inspectedElementIndex < 0) { ownerID = null; ownerFlatTree = null; diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js b/packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js index 02ecc98ec6d1..cdb50db8997d 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js @@ -37,6 +37,7 @@ import type { } from 'react-devtools-shared/src/devtools/views/Profiler/types'; const debug = (methodName: string, ...args: Array) => { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( `%cCommitTreeBuilder %c${methodName}`, @@ -101,6 +102,7 @@ export function getCommitTree({ if (operations != null && index < operations.length) { commitTree = updateTree({nodes, rootID}, operations[index]); + // $FlowFixMe[constant-condition] if (__DEBUG__) { __printTree(commitTree); } @@ -111,6 +113,7 @@ export function getCommitTree({ const previousCommitTree = commitTrees[index - 1]; commitTree = updateTree(previousCommitTree, operations[index]); + // $FlowFixMe[constant-condition] if (__DEBUG__) { __printTree(commitTree); } @@ -213,6 +216,7 @@ function updateTree( i++; // supportsStrictMode flag i++; // hasOwnerMetadata flag + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('Add', `new root fiber ${id}`); } @@ -247,6 +251,7 @@ function updateTree( // skip name prop i++; + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug( 'Add', @@ -301,6 +306,7 @@ function updateTree( } else { const parentNode = getClonedNode(parentID); + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('Remove', `fiber ${id} from parent ${parentID}`); } @@ -322,6 +328,7 @@ function updateTree( i = i + 3 + numChildren; + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('Re-order', `fiber ${id} children ${children.join(',')}`); } @@ -337,6 +344,7 @@ function updateTree( i += 3; + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug('Subtree mode', `Subtree with root ${id} set to mode ${mode}`); } @@ -348,6 +356,7 @@ function updateTree( const node = getClonedNode(id); node.treeBaseDuration = operations[i + 2] / 1000; // Convert microseconds back to milliseconds; + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug( 'Update', @@ -365,6 +374,7 @@ function updateTree( i += 4; + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug( 'Warnings and Errors update', @@ -382,6 +392,7 @@ function updateTree( const numRects = operations[i + 5]; const name = stringTable[nameStringID]; + // $FlowFixMe[constant-condition] if (__DEBUG__) { let rects: string; if (numRects === -1) { @@ -419,6 +430,7 @@ function updateTree( i = i + 3 + numChildren; + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug( 'Suspense re-order', @@ -433,6 +445,7 @@ function updateTree( const suspenseID = ((operations[i + 1]: any): number); const numRects = ((operations[i + 2]: any): number); + // $FlowFixMe[constant-condition] if (__DEBUG__) { if (numRects === -1) { debug('Suspense resize', `suspense ${suspenseID} rects null`); @@ -464,6 +477,7 @@ function updateTree( const isSuspended = operations[i++] === 1; const environmentNamesLength = operations[i++]; i += environmentNamesLength; + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug( 'Suspender changes', @@ -478,6 +492,7 @@ function updateTree( case TREE_OPERATION_APPLIED_ACTIVITY_SLICE_CHANGE: { i++; const activitySliceIDChange = operations[i++]; + // $FlowFixMe[constant-condition] if (__DEBUG__) { debug( 'Applied activity slice change', @@ -506,6 +521,7 @@ export function invalidateCommitTrees(): void { // DEBUG const __printTree = (commitTree: CommitTree) => { + // $FlowFixMe[constant-condition] if (__DEBUG__) { const {nodes, rootID} = commitTree; console.group('__printTree()'); @@ -515,6 +531,7 @@ const __printTree = (commitTree: CommitTree) => { const depth = queue.shift(); // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] const node = nodes.get(id); if (node == null) { // $FlowFixMe[incompatible-type] @@ -523,6 +540,7 @@ const __printTree = (commitTree: CommitTree) => { console.log( // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] `${'•'.repeat(depth)}${node.id}:${node.displayName || ''} ${ node.key ? `key:"${node.key}"` : '' } (${node.treeBaseDuration})`, diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/HookChangeSummary.js b/packages/react-devtools-shared/src/devtools/views/Profiler/HookChangeSummary.js index 5ce3eec42bc0..af127a9037df 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/HookChangeSummary.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/HookChangeSummary.js @@ -27,7 +27,7 @@ import Toggle from '../Toggle'; import type {HooksNode} from 'react-debug-tools/src/ReactDebugHooks'; import type {ChangeDescription} from './types'; -// $FlowFixMe: Flow doesn't know about Intl.ListFormat +// $FlowFixMe[cannot-resolve-name]: Flow doesn't know about Intl.ListFormat const hookListFormatter = new Intl.ListFormat('en', { style: 'long', type: 'conjunction', @@ -133,6 +133,7 @@ const HookChangeSummary: component(...props: Props) = memo( toggleParseHookNames(); }, [toggleParseHookNames, parseHookNames]); + // $FlowFixMe[invalid-compare] const element = fiberID !== null ? store.getElementByID(fiberID) : null; const hookNames = element != null ? getAlreadyLoadedHookNames(element) : null; diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/SidebarSelectedFiberInfo.js b/packages/react-devtools-shared/src/devtools/views/Profiler/SidebarSelectedFiberInfo.js index d785cfebdacd..430f302fbf0a 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/SidebarSelectedFiberInfo.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/SidebarSelectedFiberInfo.js @@ -67,6 +67,7 @@ export default function SidebarSelectedFiberInfo(): React.Node { const handleKeyDown = event => { switch (event.key) { case 'ArrowUp': + // $FlowFixMe[invalid-compare] if (selectedCommitIndex !== null) { const prevIndex = commitIndices.indexOf(selectedCommitIndex); const nextIndex = @@ -76,6 +77,7 @@ export default function SidebarSelectedFiberInfo(): React.Node { event.preventDefault(); break; case 'ArrowDown': + // $FlowFixMe[invalid-compare] if (selectedCommitIndex !== null) { const prevIndex = commitIndices.indexOf(selectedCommitIndex); const nextIndex = diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/Tooltip.js b/packages/react-devtools-shared/src/devtools/views/Profiler/Tooltip.js index 124be4286d1a..46c4f5582f70 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/Tooltip.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/Tooltip.js @@ -101,6 +101,7 @@ function getMousePosition( // Position within the nearest position:relative container. let targetContainer = relativeContainer; while (targetContainer.parentElement != null) { + // $FlowFixMe[invalid-compare] if (targetContainer.style.position === 'relative') { break; } else { diff --git a/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseBreadcrumbs.js b/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseBreadcrumbs.js index c542858b3016..0862cd69624f 100644 --- a/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseBreadcrumbs.js +++ b/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseBreadcrumbs.js @@ -189,6 +189,7 @@ function SuspenseBreadcrumbsMenu({ )} onPointerLeave={onItemPointerLeave} type="button"> + {/* $FlowFixMe[invalid-compare] */} {selectedSuspenseNode === null ? 'Unknown' : selectedSuspenseNode.name || 'Unknown'} diff --git a/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseRects.js b/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseRects.js index 69d4767a489f..a1a9f85411ce 100644 --- a/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseRects.js +++ b/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseRects.js @@ -522,6 +522,7 @@ function SuspenseRectsContainer({ }); } + // $FlowFixMe[incompatible-type] const isRootSelected = roots.includes(inspectedElementID); // When we're focusing a Transition, the first timeline step will not be a root. const isRootHovered = activityID === null && hoveredTimelineIndex === 0; diff --git a/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseTreeContext.js b/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseTreeContext.js index 6cb4eb7a487e..4e07336b79f7 100644 --- a/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseTreeContext.js +++ b/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseTreeContext.js @@ -168,15 +168,16 @@ function SuspenseTreeContextController({children}: Props): React.Node { } const selectedTimelineStep = + // $FlowFixMe[invalid-compare] state.timeline === null || state.timelineIndex === -1 ? null : state.timeline[state.timelineIndex]; let selectedTimelineID: null | number = null; if (selectedTimelineStep !== null) { selectedTimelineID = selectedTimelineStep.id; - // $FlowFixMe + // $FlowFixMe[incompatible-type] while (removedIDs.has(selectedTimelineID)) { - // $FlowFixMe + // $FlowFixMe[incompatible-type] selectedTimelineID = removedIDs.get(selectedTimelineID); } } @@ -258,7 +259,9 @@ function SuspenseTreeContextController({children}: Props): React.Node { // Try to reconcile the new timeline with the previous index. if ( nextRootID === null && + // $FlowFixMe[invalid-compare] previousTimeline !== null && + // $FlowFixMe[invalid-compare] previousMilestoneIndex !== null ) { const previousMilestoneID = diff --git a/packages/react-devtools-shared/src/devtools/views/hooks.js b/packages/react-devtools-shared/src/devtools/views/hooks.js index c5e426e7a622..8589ea15d016 100644 --- a/packages/react-devtools-shared/src/devtools/views/hooks.js +++ b/packages/react-devtools-shared/src/devtools/views/hooks.js @@ -243,7 +243,7 @@ export function useModalDismissSignal( const handleRootNodeClick: MouseEventHandler = event => { if ( modalRef.current !== null && - /* $FlowExpectedError[incompatible-call] Instead of dealing with possibly multiple realms + /* $FlowExpectedError[incompatible-type] Instead of dealing with possibly multiple realms and multiple Node references to comply with Flow (e.g. checking with `event.target instanceof Node`) just delegate it to contains call */ !modalRef.current.contains(event.target) diff --git a/packages/react-devtools-shared/src/dynamicImportCache.js b/packages/react-devtools-shared/src/dynamicImportCache.js index c4dfa3b7ca05..726352cc933d 100644 --- a/packages/react-devtools-shared/src/dynamicImportCache.js +++ b/packages/react-devtools-shared/src/dynamicImportCache.js @@ -52,6 +52,7 @@ function readRecord(record: Thenable): T | null { export function loadModule(moduleLoaderFunction: ModuleLoaderFunction): Module { let record = moduleLoaderFunctionToModuleMap.get(moduleLoaderFunction); + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( `[dynamicImportCache] loadModule("${moduleLoaderFunction.name}")`, @@ -103,6 +104,7 @@ export function loadModule(moduleLoaderFunction: ModuleLoaderFunction): Module { moduleLoaderFunction().then( module => { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( `[dynamicImportCache] loadModule("${moduleLoaderFunction.name}") then()`, @@ -120,6 +122,7 @@ export function loadModule(moduleLoaderFunction: ModuleLoaderFunction): Module { wake(); }, error => { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( `[dynamicImportCache] loadModule("${moduleLoaderFunction.name}") catch()`, @@ -142,6 +145,7 @@ export function loadModule(moduleLoaderFunction: ModuleLoaderFunction): Module { // Eventually timeout and stop trying to load the module. let timeoutID: null | TimeoutID = setTimeout(function onTimeout() { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( `[dynamicImportCache] loadModule("${moduleLoaderFunction.name}") onTimeout()`, diff --git a/packages/react-devtools-shared/src/hook.js b/packages/react-devtools-shared/src/hook.js index f24ae48c3601..f8778e584b87 100644 --- a/packages/react-devtools-shared/src/hook.js +++ b/packages/react-devtools-shared/src/hook.js @@ -433,7 +433,7 @@ export function installHook( const startStackFrame = openModuleRangesStack.pop(); const stopStackFrame = getTopStackFrameString(error); if (stopStackFrame !== null) { - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] moduleRanges.push([startStackFrame, stopStackFrame]); } } diff --git a/packages/react-devtools-shared/src/hookNamesCache.js b/packages/react-devtools-shared/src/hookNamesCache.js index 5a9d1ba7d212..0e3a043be17a 100644 --- a/packages/react-devtools-shared/src/hookNamesCache.js +++ b/packages/react-devtools-shared/src/hookNamesCache.js @@ -80,6 +80,7 @@ export function loadHookNames( ): HookNames | null { let record = map.get(element); + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.groupCollapsed('loadHookNames() record:'); console.log(record); @@ -151,6 +152,7 @@ export function loadHookNames( return; } + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log('[hookNamesCache] onSuccess() hookNames:', hookNames); } @@ -180,6 +182,7 @@ export function loadHookNames( return; } + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log('[hookNamesCache] onError()'); } @@ -199,6 +202,7 @@ export function loadHookNames( // Eventually timeout and stop trying to load names. timeoutID = setTimeout(function onTimeout() { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log('[hookNamesCache] onTimeout()'); } diff --git a/packages/react-devtools-shared/src/hooks/parseHookNames/loadSourceAndMetadata.js b/packages/react-devtools-shared/src/hooks/parseHookNames/loadSourceAndMetadata.js index 7c40cabf97fa..fa4235dc2c2d 100644 --- a/packages/react-devtools-shared/src/hooks/parseHookNames/loadSourceAndMetadata.js +++ b/packages/react-devtools-shared/src/hooks/parseHookNames/loadSourceAndMetadata.js @@ -128,6 +128,7 @@ function extractAndLoadSourceMapJSON( // Deduplicate fetches, since there can be multiple location keys per source map. const dedupedFetchPromises = new Map>(); + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( 'extractAndLoadSourceMapJSON() load', @@ -154,6 +155,7 @@ function extractAndLoadSourceMapJSON( ); if (sourceMappingURLMatch == null) { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log('extractAndLoadSourceMapJSON() No source map found'); } @@ -186,6 +188,7 @@ function extractAndLoadSourceMapJSON( () => JSON.parse(decoded), ); + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.groupCollapsed( 'extractAndLoadSourceMapJSON() Inline source map', @@ -271,6 +274,7 @@ function extractAndLoadSourceMapJSON( error => null, ); + // $FlowFixMe[constant-condition] if (__DEBUG__) { if (!dedupedFetchPromises.has(url)) { console.log( @@ -309,6 +313,7 @@ function fetchFile( ): Promise { return withCallbackPerfMeasurements(`${markName}("${url}")`, done => { return new Promise((resolve, reject) => { + // $FlowFixMe[incompatible-type] fetch(url, FETCH_OPTIONS).then( response => { if (response.ok) { @@ -319,6 +324,7 @@ function fetchFile( resolve(text); }) .catch(error => { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( `${markName}() Could not read text for url "${url}"`, @@ -328,6 +334,7 @@ function fetchFile( reject(null); }); } else { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log(`${markName}() Got bad response for url "${url}"`); } @@ -336,6 +343,7 @@ function fetchFile( } }, error => { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log(`${markName}() Could not fetch file: ${error.message}`); } @@ -371,6 +379,7 @@ export function flattenHooksList(hooksTree: HooksTree): HooksList { flattenHooksListImpl(hooksTree, hooksList); }); + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log('flattenHooksList() hooksList:', hooksList); } @@ -387,6 +396,7 @@ function flattenHooksListImpl( if (isUnnamedBuiltInHook(hook)) { // No need to load source code or do any parsing for unnamed hooks. + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log('flattenHooksListImpl() Skipping unnamed hook', hook); } @@ -483,6 +493,7 @@ function loadSourceFiles( throw Error('Source code too large to parse'); } + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.groupCollapsed( `loadSourceFiles() runtimeSourceURL "${runtimeSourceURL}"`, diff --git a/packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js b/packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js index fde538578572..14ab77896726 100644 --- a/packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js +++ b/packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js @@ -82,6 +82,7 @@ const originalURLToMetadataCache: LRUCache = originalSourceURL: string, metadata: CachedSourceCodeMetadata, ) => { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( `originalURLToMetadataCache.dispose() Evicting cached metadata for "${originalSourceURL}"`, @@ -183,6 +184,7 @@ function findHookNames( ); } + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log(`findHookNames() Found name "${name || '-'}"`); } @@ -301,6 +303,7 @@ function parseSourceAST( hasHookMap = true; } + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( `parseSourceAST() mapped line ${lineNumber}->${originalSourceLineNumber} and column ${columnNumber}->${originalSourceColumnNumber}`, @@ -308,6 +311,7 @@ function parseSourceAST( } if (hasHookMap) { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( `parseSourceAST() Found hookMap and skipping parsing for "${originalSourceURL}"`, @@ -319,6 +323,7 @@ function parseSourceAST( return; } + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( `parseSourceAST() Did not find hook map for "${originalSourceURL}"`, @@ -329,6 +334,7 @@ function parseSourceAST( // This may need to change if we switch to async parsing. const sourceMetadata = originalURLToMetadataCache.get(originalSourceURL); if (sourceMetadata != null) { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.groupCollapsed( `parseSourceAST() Found cached source metadata for "${originalSourceURL}"`, @@ -359,6 +365,7 @@ function parseSourceAST( ); hookParsedMetadata.originalSourceAST = originalSourceAST; + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.log( `parseSourceAST() Caching source metadata for "${originalSourceURL}"`, @@ -398,6 +405,7 @@ function parseSourceMaps( // we can skip reloading it (and more importantly, re-parsing it). const runtimeMetadata = runtimeURLToMetadataCache.get(runtimeSourceURL); if (runtimeMetadata != null) { + // $FlowFixMe[constant-condition] if (__DEBUG__) { console.groupCollapsed( `parseHookNames() Found cached runtime metadata for file "${runtimeSourceURL}"`, diff --git a/packages/react-devtools-shared/src/inspectedElementMutableSource.js b/packages/react-devtools-shared/src/inspectedElementMutableSource.js index d967109163aa..4db8c812f4ea 100644 --- a/packages/react-devtools-shared/src/inspectedElementMutableSource.js +++ b/packages/react-devtools-shared/src/inspectedElementMutableSource.js @@ -143,6 +143,7 @@ export function inspectElement( // A path has been hydrated. // Merge it with the latest copy we have locally and resolve with the merged value. inspectedElement = inspectedElementCache.get(id) || null; + // $FlowFixMe[invalid-compare] if (inspectedElement !== null) { // Clone element inspectedElement = {...inspectedElement}; diff --git a/packages/react-devtools-shared/src/utils.js b/packages/react-devtools-shared/src/utils.js index aa7ba33dc595..69c4b5d8aa4f 100644 --- a/packages/react-devtools-shared/src/utils.js +++ b/packages/react-devtools-shared/src/utils.js @@ -597,7 +597,7 @@ export function parseElementDisplayNameFromBackend( } return { - // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] formattedDisplayName: displayName, hocDisplayNames, compiledWithForget: false, @@ -976,6 +976,7 @@ export function formatDataForPreview( case 'html_element': return `<${truncateForDisplay(data.tagName.toLowerCase())} />`; case 'function': + // $FlowFixMe[invalid-compare] if (typeof data.name === 'function' || data.name === '') { return '() => {}'; } diff --git a/packages/react-devtools-shell/src/app/Iframe/index.js b/packages/react-devtools-shell/src/app/Iframe/index.js index 7f3964971cf8..3f861f7beead 100644 --- a/packages/react-devtools-shell/src/app/Iframe/index.js +++ b/packages/react-devtools-shell/src/app/Iframe/index.js @@ -28,6 +28,7 @@ function Frame(props) { React.useLayoutEffect(function () { const iframe = ref.current; + // $FlowFixMe[constant-condition] if (iframe) { const html = ` @@ -57,6 +58,7 @@ function Frame(props) { style={iframeStyle} /> + {/* $FlowFixMe[constant-condition] */} {element ? createPortal(props.children, element) : null} ); diff --git a/packages/react-devtools-shell/src/app/InspectableElements/CustomHooks.js b/packages/react-devtools-shell/src/app/InspectableElements/CustomHooks.js index 487c0be4da75..c0a543d44147 100644 --- a/packages/react-devtools-shell/src/app/InspectableElements/CustomHooks.js +++ b/packages/react-devtools-shell/src/app/InspectableElements/CustomHooks.js @@ -72,7 +72,7 @@ function useDeepHookF() { const ContextA = createContext('A'); const ContextB = createContext('B'); -function FunctionWithHooks(props: any, ref: React$RefSetter) { +function FunctionWithHooks(props: any, ref: React.RefSetter) { const [count, updateCount] = useState(0); // eslint-disable-next-line no-unused-vars const contextValueA = useContext(ContextA); @@ -109,7 +109,7 @@ const MemoWithHooks = memo(FunctionWithHooks); const ForwardRefWithHooks = forwardRef(FunctionWithHooks); function wrapWithHoc( - Component: (props: any, ref: React$RefSetter) => any, + Component: (props: any, ref: React.RefSetter) => any, ) { function Hoc() { return ; diff --git a/packages/react-devtools-shell/src/app/index.js b/packages/react-devtools-shell/src/app/index.js index d23b8ca7a451..78cd9478362d 100644 --- a/packages/react-devtools-shell/src/app/index.js +++ b/packages/react-devtools-shell/src/app/index.js @@ -95,7 +95,7 @@ function mountLegacyApp(App: () => React$Node) { // $FlowFixMe[not-a-function]: These are removed in 19. render(createElement(LegacyRender), container); - // $FlowFixMe: These are removed in 19. + // $FlowFixMe[not-a-function]: These are removed in 19. unmountFunctions.push(() => unmountComponentAtNode(container)); } diff --git a/packages/react-devtools-timeline/src/CanvasPage.js b/packages/react-devtools-timeline/src/CanvasPage.js index 9e861c2712ad..104a92727d52 100644 --- a/packages/react-devtools-timeline/src/CanvasPage.js +++ b/packages/react-devtools-timeline/src/CanvasPage.js @@ -438,6 +438,7 @@ function AutoSizedCanvas({ if (suspenseEventsViewWrapper !== null) { rootView.addSubview(suspenseEventsViewWrapper); } + // $FlowFixMe[invalid-compare] if (reactMeasuresViewWrapper !== null) { rootView.addSubview(reactMeasuresViewWrapper); } diff --git a/packages/react-devtools-timeline/src/content-views/SnapshotsView.js b/packages/react-devtools-timeline/src/content-views/SnapshotsView.js index 494cca38c4fc..23d61a3b63b2 100644 --- a/packages/react-devtools-timeline/src/content-views/SnapshotsView.js +++ b/packages/react-devtools-timeline/src/content-views/SnapshotsView.js @@ -166,7 +166,7 @@ export class SnapshotsView extends View { imageRect.size.height, ); - // $FlowFixMe[incompatible-call] Flow doesn't know about the 9 argument variant of drawImage() + // $FlowFixMe[incompatible-type] Flow doesn't know about the 9 argument variant of drawImage() context.drawImage( snapshot.image, diff --git a/packages/react-devtools-timeline/src/content-views/UserTimingMarksView.js b/packages/react-devtools-timeline/src/content-views/UserTimingMarksView.js index 3128777a9c07..8967d8463dfa 100644 --- a/packages/react-devtools-timeline/src/content-views/UserTimingMarksView.js +++ b/packages/react-devtools-timeline/src/content-views/UserTimingMarksView.js @@ -106,6 +106,7 @@ export class UserTimingMarksView extends View { ? COLORS.USER_TIMING_HOVER : COLORS.USER_TIMING; + // $FlowFixMe[invalid-compare] if (fillStyle !== null) { const y = baseY + halfSize; diff --git a/packages/react-devtools-timeline/src/import-worker/preprocessData.js b/packages/react-devtools-timeline/src/import-worker/preprocessData.js index 8d45be544d74..f54b7b0f7870 100644 --- a/packages/react-devtools-timeline/src/import-worker/preprocessData.js +++ b/packages/react-devtools-timeline/src/import-worker/preprocessData.js @@ -283,10 +283,12 @@ function processEventDispatch( warning: null, }; + // $FlowFixMe[incompatible-type] profilerData.nativeEvents.push(nativeEvent); // Keep track of curent event in case future ones overlap. // We separate them into different vertical lanes in this case. + // $FlowFixMe[incompatible-type] state.nativeEventStack.push(nativeEvent); } } diff --git a/packages/react-devtools-timeline/src/view-base/useCanvasInteraction.js b/packages/react-devtools-timeline/src/view-base/useCanvasInteraction.js index 59fd89c26f35..0f2bf0e87c46 100644 --- a/packages/react-devtools-timeline/src/view-base/useCanvasInteraction.js +++ b/packages/react-devtools-timeline/src/view-base/useCanvasInteraction.js @@ -125,7 +125,7 @@ export function useCanvasInteraction( } function localToCanvasCoordinates(localCoordinates: Point): Point { - // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] found when upgrading Flow const canvasRect = cacheFirstGetCanvasBoundingRect(canvas); return { x: localCoordinates.x - canvasRect.left, diff --git a/packages/react-dom-bindings/src/client/DOMPropertyOperations.js b/packages/react-dom-bindings/src/client/DOMPropertyOperations.js index df09445acc55..72ed2ae4f924 100644 --- a/packages/react-dom-bindings/src/client/DOMPropertyOperations.js +++ b/packages/react-dom-bindings/src/client/DOMPropertyOperations.js @@ -212,7 +212,7 @@ export function setValueForPropertyOnCustomComponent( node.removeAttribute(name); } } - // $FlowFixMe[incompatible-cast] value can't be casted to EventListener. + // $FlowFixMe[incompatible-type] value can't be casted to EventListener. node.addEventListener(eventName, (value: EventListener), useCapture); return; } diff --git a/packages/react-dom-bindings/src/client/ReactDOMComponent.js b/packages/react-dom-bindings/src/client/ReactDOMComponent.js index 80ee96a87a8f..78376e4922a2 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMComponent.js +++ b/packages/react-dom-bindings/src/client/ReactDOMComponent.js @@ -2120,6 +2120,7 @@ function hydrateAttribute( if (__DEV__) { checkAttributeStringCoercion(value, propKey); } + // $FlowFixMe[invalid-compare] if (serverValue === '' + value) { return; } @@ -2184,6 +2185,7 @@ function hydrateOverloadedBooleanAttribute( case 'symbol': return; default: + // $FlowFixMe[invalid-compare] if (value === false) { return; } @@ -2198,6 +2200,7 @@ function hydrateOverloadedBooleanAttribute( case 'symbol': break; case 'boolean': + // $FlowFixMe[invalid-compare] if (value === true && serverValue === '') { return; } @@ -2206,6 +2209,7 @@ function hydrateOverloadedBooleanAttribute( if (__DEV__) { checkAttributeStringCoercion(value, propKey); } + // $FlowFixMe[invalid-compare] if (serverValue === '' + value) { return; } @@ -2297,6 +2301,7 @@ function hydrateNumericAttribute( if (__DEV__) { checkAttributeStringCoercion(value, propKey); } + // $FlowFixMe[invalid-compare] if (serverValue === '' + value) { return; } @@ -2348,6 +2353,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 b6e665e12883..0ae9824cb849 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 bc346b4bce40..75fe6b8fabce 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 1ae2f663c72c..f21c1b6154e6 100644 --- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js +++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js @@ -1112,6 +1112,7 @@ export function appendChildToContainer( // https://github.com/facebook/react/issues/11918 const reactRootContainer = container._reactRootContainer; if ( + // $FlowFixMe[invalid-compare] (reactRootContainer === null || reactRootContainer === undefined) && parentNode.onclick === null ) { @@ -1419,6 +1420,7 @@ export function unhideInstance(instance: Instance, props: Props): void { const styleProp = props[STYLE]; const display = styleProp !== undefined && + // $FlowFixMe[invalid-compare] styleProp !== null && styleProp.hasOwnProperty('display') ? styleProp.display @@ -1525,7 +1527,7 @@ export function applyViewTransitionName( // https://bugs.webkit.org/show_bug.cgi?id=290923 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 @@ -1632,7 +1634,7 @@ export function cancelViewTransitionName( if (documentElement !== null) { documentElement.animate( {opacity: [0, 0], pointerEvents: ['none', 'none']}, - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] { duration: 0, fill: 'forwards', @@ -1669,7 +1671,7 @@ export function cancelRootViewTransitionName(rootContainer: Container): void { documentElement.style.viewTransitionName = 'none'; documentElement.animate( {opacity: [0, 0], pointerEvents: ['none', 'none']}, - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] { duration: 0, fill: 'forwards', @@ -1686,6 +1688,7 @@ export function cancelRootViewTransitionName(rootContainer: Container): void { documentElement.animate( {width: [0, 0], height: [0, 0]}, // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] { duration: 0, fill: 'forwards', @@ -1782,11 +1785,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 @@ -1869,7 +1872,7 @@ export function cloneRootViewTransitionContainer( if (getComputedStyle(positionedAncestor).position !== 'static') { break; } - // $FlowFixMe: This is refined. + // $FlowFixMe[incompatible-type]: This is refined. positionedAncestor = positionedAncestor.parentNode; } @@ -2267,11 +2270,12 @@ export function startViewTransition( const documentElement: Element = (ownerDocument.documentElement: any); // Loop through all View Transition Animations. // $FlowFixMe[prop-missing] + // $FlowFixMe[incompatible-type] const animations = documentElement.getAnimations({subtree: true}); for (let i = 0; i < animations.length; i++) { const animation = animations[i]; const effect: KeyframeEffect = (animation.effect: any); - // $FlowFixMe + // $FlowFixMe[prop-missing] const pseudoElement: ?string = effect.pseudoElement; if ( pseudoElement != null && @@ -2313,13 +2317,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[prop-missing] effect.pseudoElement, ); if ( @@ -2334,7 +2338,7 @@ export function startViewTransition( const last = keyframes[keyframes.length - 1]; last.width = width; last.height = height; - // $FlowFixMe + // $FlowFixMe[incompatible-type] effect.setKeyframes(keyframes); } } @@ -2536,7 +2540,7 @@ function animateGesture( const reverse = rangeStart > rangeEnd; if (timeline instanceof AnimationTimeline) { // Native Timeline - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] const animation = targetElement.animate(keyframes, { pseudoElement: pseudoElement, // Set the timeline to the current gesture timeline to drive the updates. @@ -2558,7 +2562,7 @@ function animateGesture( viewTransitionAnimations.push(animation); } else { // Custom Timeline - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] const animation = targetElement.animate(keyframes, { pseudoElement: pseudoElement, // We reset all easing functions to linear so that it feels like you @@ -2617,6 +2621,7 @@ export function startGestureTransition( const documentElement: Element = (ownerDocument.documentElement: any); // Loop through all View Transition Animations. // $FlowFixMe[prop-missing] + // $FlowFixMe[incompatible-type] const animations = documentElement.getAnimations({subtree: true}); // First do a pass to collect all known group and new items so we can look // up if they exist later. @@ -2626,7 +2631,7 @@ export function startGestureTransition( let longestDuration = 0; for (let i = 0; i < animations.length; i++) { const effect: KeyframeEffect = (animations[i].effect: any); - // $FlowFixMe + // $FlowFixMe[prop-missing] const pseudoElement: ?string = effect.pseudoElement; if (pseudoElement == null) { } else if ( @@ -2661,7 +2666,7 @@ export function startGestureTransition( continue; } const effect: KeyframeEffect = (anim.effect: any); - // $FlowFixMe + // $FlowFixMe[prop-missing] const pseudoElement: ?string = effect.pseudoElement; if ( pseudoElement != null && @@ -2721,7 +2726,7 @@ export function startGestureTransition( } animateGesture( effect.getKeyframes(), - // $FlowFixMe: Always documentElement atm. + // $FlowFixMe[incompatible-type]: Always documentElement atm. effect.target, pseudoElement, timeline, @@ -2749,7 +2754,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, @@ -2770,6 +2775,7 @@ export function startGestureTransition( // that never stops. This seems to keep all running Animations alive until // we explicitly abort (or something forces the View Transition to cancel). // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] const blockingAnim = documentElement.animate([{}, {}], { pseudoElement: '::view-transition', duration: 1, @@ -2892,6 +2898,7 @@ ViewTransitionPseudoElement.prototype.animate = function ( } : Object.assign( (// $FlowFixMe[prop-missing] + // $FlowFixMe[incompatible-type] {}: KeyframeAnimationOptions), options, ); @@ -2908,6 +2915,7 @@ ViewTransitionPseudoElement.prototype.getAnimations = function ( const selector = this._selector; const animations = scope.getAnimations( // $FlowFixMe[prop-missing] + // $FlowFixMe[incompatible-type] {subtree: true}, ); const result = []; @@ -3352,7 +3360,7 @@ FragmentInstance.prototype.getRootNode = function ( const parentHostInstance = getInstanceFromHostFiber(parentHostFiber); const rootNode = - // $FlowFixMe[incompatible-cast] Flow expects Node + // $FlowFixMe[incompatible-type] Flow expects Node (parentHostInstance.getRootNode(getRootNodeOptions): Document | ShadowRoot); return rootNode; }; @@ -3476,6 +3484,7 @@ function validateDocumentPositionWithFiberTree( if (otherFiber === null) { // otherFiber could be null if its the document or body element const ownerDocument = otherNode.ownerDocument; + // $FlowFixMe[invalid-compare] return otherNode === ownerDocument || otherNode === ownerDocument.body; } return isFragmentContainedByFiber(fragmentFiber, otherFiber); @@ -4829,11 +4838,11 @@ export type HoistableRoot = Document | ShadowRoot; export function getHoistableRoot(container: Container): HoistableRoot { // $FlowFixMe[method-unbinding] return typeof container.getRootNode === 'function' - ? /* $FlowFixMe[incompatible-cast] Flow types this as returning a `Node`, + ? /* $FlowFixMe[incompatible-type] Flow types this as returning a `Node`, * but it's either a `Document` or `ShadowRoot`. */ (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] We've constrained this to be a Document which satisfies the return type (container: Document) : container.ownerDocument; } @@ -5151,12 +5160,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; } @@ -5570,7 +5581,7 @@ function preloadStylesheet( markNodeAsHoistable(instance); (ownerDocument.head: any).appendChild(instance); } - // $FlowFixMe: [incompatible-type] -- if instance is an Element it will also be an HTMLLinkElement + // $FlowFixMe[incompatible-type] -- if instance is an Element it will also be an HTMLLinkElement state.preload = instance; instance.addEventListener('load', () => (state.loading |= Loaded)); instance.addEventListener('error', () => (state.loading |= Errored)); diff --git a/packages/react-dom-bindings/src/client/estimateBandwidth.js b/packages/react-dom-bindings/src/client/estimateBandwidth.js index 4b143a5b562c..5f484aebd95b 100644 --- a/packages/react-dom-bindings/src/client/estimateBandwidth.js +++ b/packages/react-dom-bindings/src/client/estimateBandwidth.js @@ -98,7 +98,7 @@ export default function estimateBandwidth(): number { // Fallback to the navigator.connection estimate if available // $FlowFixMe[prop-missing] if (navigator.connection) { - // $FlowFixMe + // $FlowFixMe[incompatible-use] const downlink: ?number = navigator.connection.downlink; if (typeof downlink === 'number') { return downlink; diff --git a/packages/react-dom-bindings/src/client/validateDOMNesting.js b/packages/react-dom-bindings/src/client/validateDOMNesting.js index 47aef9353ba8..1431b8111ac0 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] 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 e30c4798371d..da605f35b236 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,7 @@ function accumulateEnterLeaveListenersForEvent( createDispatchListener(instance, captureListener, currentTarget), ); } + // $FlowFixMe[constant-condition] } 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 2763b2fc129a..c9ae44810df4 100644 --- a/packages/react-dom-bindings/src/events/ReactDOMEventReplaying.js +++ b/packages/react-dom-bindings/src/events/ReactDOMEventReplaying.js @@ -216,6 +216,7 @@ function accumulateOrCreateContinuousQueuedReplayableEvent( existingQueuedEvent.eventSystemFlags |= eventSystemFlags; const targetContainers = existingQueuedEvent.targetContainers; if ( + // $FlowFixMe[invalid-compare] targetContainer !== null && targetContainers.indexOf(targetContainer) === -1 ) { diff --git a/packages/react-dom-bindings/src/events/SyntheticEvent.js b/packages/react-dom-bindings/src/events/SyntheticEvent.js index 11ec03091941..1fa5dafba11b 100644 --- a/packages/react-dom-bindings/src/events/SyntheticEvent.js +++ b/packages/react-dom-bindings/src/events/SyntheticEvent.js @@ -391,7 +391,7 @@ function getEventKey(nativeEvent: {[propName: string]: mixed}) { // Browser does not implement `key`, polyfill as much of it as we can. if (nativeEvent.type === 'keypress') { const charCode = getEventCharCode( - // $FlowFixMe[incompatible-call] unable to narrow to `KeyboardEvent` + // $FlowFixMe[incompatible-type] unable to narrow to `KeyboardEvent` nativeEvent, ); @@ -463,7 +463,7 @@ const KeyboardEventInterface: EventInterfaceType = { // implemented in any major browser. Only KeyPress has charCode. if (event.type === 'keypress') { return getEventCharCode( - // $FlowFixMe[incompatible-call] unable to narrow to `KeyboardEvent` + // $FlowFixMe[incompatible-type] unable to narrow to `KeyboardEvent` event, ); } @@ -487,7 +487,7 @@ const KeyboardEventInterface: EventInterfaceType = { // type of the event. if (event.type === 'keypress') { return getEventCharCode( - // $FlowFixMe[incompatible-call] unable to narrow to `KeyboardEvent` + // $FlowFixMe[incompatible-type] unable to narrow to `KeyboardEvent` event, ); } diff --git a/packages/react-dom-bindings/src/server/ReactDOMLegacyServerStreamConfig.js b/packages/react-dom-bindings/src/server/ReactDOMLegacyServerStreamConfig.js index 54c576856869..6696dcdf6521 100644 --- a/packages/react-dom-bindings/src/server/ReactDOMLegacyServerStreamConfig.js +++ b/packages/react-dom-bindings/src/server/ReactDOMLegacyServerStreamConfig.js @@ -75,7 +75,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]: This is an Error object or the destination accepts other types. destination.destroy(error); } diff --git a/packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js b/packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js index 8a13babe2b91..ad799c6d0c66 100644 --- a/packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js +++ b/packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js @@ -13,7 +13,7 @@ if (document.body != null) { if (document.readyState === 'loading') { 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 @@ -25,7 +25,7 @@ if (document.body != null) { if (document.readyState === 'loading') { installFizzInstrObserver(document.body); } - // $FlowFixMe[incompatible-cast] + // $FlowFixMe[incompatible-type] handleExistingNodes((document.body: HTMLElement)); // We can call disconnect without takeRecord here, @@ -69,11 +69,11 @@ 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-bindings/src/server/ReactFizzConfigDOM.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js index 691e49e563fd..380a34aa01ce 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); @@ -3367,7 +3368,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-type] - Flow should understand that this is a Resource if the condition was true renderState.highImagePreloads.add(resource); } } else if (!resumableState.imageResources.hasOwnProperty(key)) { @@ -3563,6 +3564,8 @@ function pushTitle( ' tags to a single string value.', childType, ); + // $FlowFixMe[invalid-compare] + // $FlowFixMe[constant-condition] } else if (child && child.toString === {}.toString) { if (child.$$typeof != null) { console.error( @@ -4019,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') { @@ -4612,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/ReactDOMClientFB.js b/packages/react-dom/src/client/ReactDOMClientFB.js index 872a4550aa36..58254e64ec8a 100644 --- a/packages/react-dom/src/client/ReactDOMClientFB.js +++ b/packages/react-dom/src/client/ReactDOMClientFB.js @@ -82,7 +82,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] The Flow type is opaque but there's no way to actually create it. return createPortalImpl(children, container, null, key); } @@ -100,7 +100,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/ReactDOMDefaultTransitionIndicator.js b/packages/react-dom/src/client/ReactDOMDefaultTransitionIndicator.js index 37661849cad8..b345480312dc 100644 --- a/packages/react-dom/src/client/ReactDOMDefaultTransitionIndicator.js +++ b/packages/react-dom/src/client/ReactDOMDefaultTransitionIndicator.js @@ -43,11 +43,11 @@ export function defaultOnDefaultTransitionIndicator(): void | (() => void) { } } - // $FlowFixMe + // $FlowFixMe[incompatible-type] navigation.addEventListener('navigate', handleNavigate); - // $FlowFixMe + // $FlowFixMe[incompatible-type] navigation.addEventListener('navigatesuccess', handleNavigateComplete); - // $FlowFixMe + // $FlowFixMe[incompatible-type] navigation.addEventListener('navigateerror', handleNavigateComplete); function startFakeNavigation() { @@ -76,11 +76,11 @@ export function defaultOnDefaultTransitionIndicator(): void | (() => void) { return function () { isCancelled = true; - // $FlowFixMe + // $FlowFixMe[incompatible-type] navigation.removeEventListener('navigate', handleNavigate); - // $FlowFixMe + // $FlowFixMe[incompatible-type] navigation.removeEventListener('navigatesuccess', handleNavigateComplete); - // $FlowFixMe + // $FlowFixMe[incompatible-type] navigation.removeEventListener('navigateerror', handleNavigateComplete); if (pendingResolve !== null) { pendingResolve(); diff --git a/packages/react-dom/src/client/ReactDOMRoot.js b/packages/react-dom/src/client/ReactDOMRoot.js index a32cefe81d5b..8437024f8547 100644 --- a/packages/react-dom/src/client/ReactDOMRoot.js +++ b/packages/react-dom/src/client/ReactDOMRoot.js @@ -187,6 +187,7 @@ export function createRoot( let onDefaultTransitionIndicator = defaultOnDefaultTransitionIndicator; let transitionCallbacks = null; + // $FlowFixMe[invalid-compare] if (options !== null && options !== undefined) { if (__DEV__) { if ((options: any).hydrate) { @@ -196,6 +197,7 @@ export function createRoot( } else { if ( typeof options === 'object' && + // $FlowFixMe[invalid-compare] options !== null && (options: any).$$typeof === REACT_ELEMENT_TYPE ) { @@ -304,6 +306,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/client/ReactDOMRootFB.js b/packages/react-dom/src/client/ReactDOMRootFB.js index 3a0205fe799c..3822c82dca16 100644 --- a/packages/react-dom/src/client/ReactDOMRootFB.js +++ b/packages/react-dom/src/client/ReactDOMRootFB.js @@ -255,7 +255,7 @@ function legacyCreateRootFromDOMContainer( !disableCommentsAsDOMContainers && container.nodeType === COMMENT_NODE ? container.parentNode : container; - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] listenToAllSupportedEvents(rootContainerElement); flushSyncWork(); @@ -292,7 +292,7 @@ function legacyCreateRootFromDOMContainer( !disableCommentsAsDOMContainers && container.nodeType === COMMENT_NODE ? container.parentNode : container; - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] listenToAllSupportedEvents(rootContainerElement); // Initial mount should not be batched. @@ -425,6 +425,7 @@ export function render( } return legacyRenderSubtreeIntoContainer( null, + // $FlowFixMe[incompatible-type] element, container, false, diff --git a/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js b/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js index 75c0768b3248..e6a0619c0e77 100644 --- a/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js +++ b/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js @@ -97,6 +97,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ): any); // TODO: Move to sub-classing ReadableStream. @@ -188,6 +189,7 @@ function resume( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ): any); // TODO: Move to sub-classing ReadableStream. diff --git a/packages/react-dom/src/server/ReactDOMFizzServerBun.js b/packages/react-dom/src/server/ReactDOMFizzServerBun.js index 90d6ccdad2e5..d41481b355ae 100644 --- a/packages/react-dom/src/server/ReactDOMFizzServerBun.js +++ b/packages/react-dom/src/server/ReactDOMFizzServerBun.js @@ -78,7 +78,7 @@ function renderToReadableStream( { type: 'direct', pull: (controller): ?Promise => { - // $FlowIgnore + // $FlowFixMe[incompatible-type] startFlowing(request, controller); }, cancel: (reason): ?Promise => { @@ -87,6 +87,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 2048}, ): any); // TODO: Move to sub-classing ReadableStream. diff --git a/packages/react-dom/src/server/ReactDOMFizzServerEdge.js b/packages/react-dom/src/server/ReactDOMFizzServerEdge.js index 75c0768b3248..e6a0619c0e77 100644 --- a/packages/react-dom/src/server/ReactDOMFizzServerEdge.js +++ b/packages/react-dom/src/server/ReactDOMFizzServerEdge.js @@ -97,6 +97,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ): any); // TODO: Move to sub-classing ReadableStream. @@ -188,6 +189,7 @@ function resume( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ): any); // TODO: Move to sub-classing ReadableStream. diff --git a/packages/react-dom/src/server/ReactDOMFizzServerNode.js b/packages/react-dom/src/server/ReactDOMFizzServerNode.js index c0a3cf1096eb..4ca18fdf271e 100644 --- a/packages/react-dom/src/server/ReactDOMFizzServerNode.js +++ b/packages/react-dom/src/server/ReactDOMFizzServerNode.js @@ -234,6 +234,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ): any); // TODO: Move to sub-classing ReadableStream. @@ -392,6 +393,7 @@ function resume( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ): any); // TODO: Move to sub-classing ReadableStream. diff --git a/packages/react-dom/src/server/ReactDOMFizzStaticBrowser.js b/packages/react-dom/src/server/ReactDOMFizzStaticBrowser.js index c1024ea3f4d3..6a4c2d3059c8 100644 --- a/packages/react-dom/src/server/ReactDOMFizzStaticBrowser.js +++ b/packages/react-dom/src/server/ReactDOMFizzStaticBrowser.js @@ -84,6 +84,7 @@ function prerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); @@ -172,6 +173,7 @@ function resumeAndPrerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); diff --git a/packages/react-dom/src/server/ReactDOMFizzStaticEdge.js b/packages/react-dom/src/server/ReactDOMFizzStaticEdge.js index 002c4c51b44f..1b2deb4b8752 100644 --- a/packages/react-dom/src/server/ReactDOMFizzStaticEdge.js +++ b/packages/react-dom/src/server/ReactDOMFizzStaticEdge.js @@ -84,6 +84,7 @@ function prerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); @@ -170,6 +171,7 @@ function resumeAndPrerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); diff --git a/packages/react-dom/src/server/ReactDOMFizzStaticNode.js b/packages/react-dom/src/server/ReactDOMFizzStaticNode.js index 73abcadeb7a7..4eafdcba6ddf 100644 --- a/packages/react-dom/src/server/ReactDOMFizzStaticNode.js +++ b/packages/react-dom/src/server/ReactDOMFizzStaticNode.js @@ -206,6 +206,7 @@ function prerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); @@ -348,6 +349,7 @@ function resumeAndPrerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); diff --git a/packages/react-dom/src/shared/ReactDOM.js b/packages/react-dom/src/shared/ReactDOM.js index f1d48bfacd4d..dc4c73316f6b 100644 --- a/packages/react-dom/src/shared/ReactDOM.js +++ b/packages/react-dom/src/shared/ReactDOM.js @@ -63,7 +63,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] The Flow type is opaque but there's no way to actually create it. return createPortalImpl(children, container, null, key); } diff --git a/packages/react-dom/src/shared/ReactDOMFloat.js b/packages/react-dom/src/shared/ReactDOMFloat.js index 844824fd0667..4d916308eb1b 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-dom/src/test-utils/FizzTestUtils.js b/packages/react-dom/src/test-utils/FizzTestUtils.js index 4d8b6cadbabf..aabaf9306b68 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-flight-server-fb/src/ReactFlightFBReferences.js b/packages/react-flight-server-fb/src/ReactFlightFBReferences.js index d639467f6bd3..d730a0aa07c9 100644 --- a/packages/react-flight-server-fb/src/ReactFlightFBReferences.js +++ b/packages/react-flight-server-fb/src/ReactFlightFBReferences.js @@ -51,7 +51,7 @@ const FunctionBind = Function.prototype.bind; // $FlowFixMe[method-unbinding] 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-flight-server-fb/src/ReactServerStreamConfigFB.js b/packages/react-flight-server-fb/src/ReactServerStreamConfigFB.js index be6f854f1b02..29c1ccfe2685 100644 --- a/packages/react-flight-server-fb/src/ReactServerStreamConfigFB.js +++ b/packages/react-flight-server-fb/src/ReactServerStreamConfigFB.js @@ -223,7 +223,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]: This is an Error object or the destination accepts other types. destination.destroy(error); } diff --git a/packages/react-flight-server-fb/src/client/ReactFlightClientConfigBundlerFB.js b/packages/react-flight-server-fb/src/client/ReactFlightClientConfigBundlerFB.js index 79213ec360ac..b1ebf9278889 100644 --- a/packages/react-flight-server-fb/src/client/ReactFlightClientConfigBundlerFB.js +++ b/packages/react-flight-server-fb/src/client/ReactFlightClientConfigBundlerFB.js @@ -164,7 +164,7 @@ export function getModuleDebugInfo( if (ioInfo === undefined) { let href; try { - // $FlowFixMe + // $FlowFixMe[incompatible-type] href = new URL(filename, document.baseURI).href; } catch (_) { href = filename; @@ -187,10 +187,10 @@ export function getModuleDebugInfo( } } const value = Promise.resolve(href); - // $FlowFixMe + // $FlowFixMe[prop-missing] value.status = 'fulfilled'; // Is there some more useful representation for the chunk? - // $FlowFixMe + // $FlowFixMe[prop-missing] value.value = href; // Create a fake stack frame that points to the beginning of the chunk. This is // probably not source mapped so will link to the compiled source rather than diff --git a/packages/react-flight-server-fb/src/server/ReactFlightDOMServerNode.js b/packages/react-flight-server-fb/src/server/ReactFlightDOMServerNode.js index eb481f0d772f..b0ecd41f27ab 100644 --- a/packages/react-flight-server-fb/src/server/ReactFlightDOMServerNode.js +++ b/packages/react-flight-server-fb/src/server/ReactFlightDOMServerNode.js @@ -144,11 +144,11 @@ function startReadingFromDebugChannelReadable( const ws: WebSocket = (stream: any); ws.binaryType = 'arraybuffer'; ws.addEventListener('message', event => { - // $FlowFixMe + // $FlowFixMe[incompatible-type] onData(event.data); }); ws.addEventListener('error', event => { - // $FlowFixMe + // $FlowFixMe[prop-missing] onError(event.error); }); ws.addEventListener('close', onClose); @@ -339,7 +339,7 @@ function decodeReplyFromBusboy( busboyStream.on('error', err => { reportGlobalError( response, - // $FlowFixMe[incompatible-call] types Error and mixed are incompatible + // $FlowFixMe[incompatible-type] types Error and mixed are incompatible err, ); }); diff --git a/packages/react-markup/src/ReactMarkupServer.js b/packages/react-markup/src/ReactMarkupServer.js index 43e258bf13ef..500d61393a42 100644 --- a/packages/react-markup/src/ReactMarkupServer.js +++ b/packages/react-markup/src/ReactMarkupServer.js @@ -179,7 +179,7 @@ export function experimental_renderToHTML( } } const flightRequest = createFlightRequest( - // $FlowFixMe: This should be a subtype but not everything is typed covariant. + // $FlowFixMe[incompatible-type]: This should be a subtype but not everything is typed covariant. children, null, handleFlightError, @@ -196,7 +196,7 @@ export function experimental_renderToHTML( ); const root = getFlightRoot(flightResponse); const fizzRequest = createFizzRequest( - // $FlowFixMe: Thenables as children are supported. + // $FlowFixMe[incompatible-type]: Thenables as children are supported. root, resumableState, createRenderState( diff --git a/packages/react-native-renderer/src/ReactFabric.js b/packages/react-native-renderer/src/ReactFabric.js index 30c32433b3b6..d91431bd6f92 100644 --- a/packages/react-native-renderer/src/ReactFabric.js +++ b/packages/react-native-renderer/src/ReactFabric.js @@ -151,6 +151,7 @@ function render( // TODO (bvaughn): If we decide to keep the wrapper component, // We could create a wrapper for containerTag as well to reduce special casing. root = createContainer( + // $FlowFixMe[incompatible-type] rootInstance, concurrentRoot ? ConcurrentRoot : LegacyRoot, null, @@ -166,6 +167,7 @@ function render( roots.set(containerTag, root); } + // $FlowFixMe[incompatible-type] updateContainer(element, root, null, callback); return getPublicRootInstance(root); diff --git a/packages/react-native-renderer/src/ReactFabricComponentTree.js b/packages/react-native-renderer/src/ReactFabricComponentTree.js index f36e742a45ab..e48e57810f79 100644 --- a/packages/react-native-renderer/src/ReactFabricComponentTree.js +++ b/packages/react-native-renderer/src/ReactFabricComponentTree.js @@ -29,7 +29,7 @@ function getInstanceFromNode(node: Instance | TextInstance): Fiber | null { return instance.canonical.internalInstanceHandle; } - // $FlowFixMe[incompatible-return] DevTools incorrectly passes a fiber in React Native. + // $FlowFixMe[incompatible-type] DevTools incorrectly passes a fiber in React Native. return node; } diff --git a/packages/react-native-renderer/src/ReactFabricEventEmitter.js b/packages/react-native-renderer/src/ReactFabricEventEmitter.js index c7f6aebd9028..22dbdcabc828 100644 --- a/packages/react-native-renderer/src/ReactFabricEventEmitter.js +++ b/packages/react-native-renderer/src/ReactFabricEventEmitter.js @@ -103,7 +103,7 @@ export function dispatchEvent( const stateNode = targetFiber.stateNode; // Guard against Fiber being unmounted if (stateNode != null) { - // $FlowExpectedError[incompatible-cast] public instances in Fabric do not implement `EventTarget` yet. + // $FlowExpectedError[incompatible-type] public instances in Fabric do not implement `EventTarget` yet. eventTarget = (getPublicInstance(stateNode): EventTarget); } } diff --git a/packages/react-native-renderer/src/ReactFiberConfigFabric.js b/packages/react-native-renderer/src/ReactFiberConfigFabric.js index 29beb80db91b..c9b037d53b1f 100644 --- a/packages/react-native-renderer/src/ReactFiberConfigFabric.js +++ b/packages/react-native-renderer/src/ReactFiberConfigFabric.js @@ -155,6 +155,7 @@ export type RendererInspectionConfig = $ReadOnly<{ }>; // TODO: Remove this conditional once all changes have propagated. +// $FlowFixMe[constant-condition] if (registerEventHandler) { /** * Register the event emitter with the native bridge @@ -392,6 +393,7 @@ export function resolveUpdatePriority(): EventPriority { return currentUpdatePriority; } + // $FlowFixMe[constant-condition] const currentEventPriority = fabricGetCurrentEventPriority ? fabricGetCurrentEventPriority() : null; @@ -705,8 +707,9 @@ FragmentInstance.prototype.observeUsing = function ( traverseFragmentInstance(this._fragmentFiber, observeChild, observer); }; function observeChild(child: Fiber, observer: IntersectionObserver) { + // $FlowFixMe[incompatible-type] const publicInstance = getPublicInstanceFromHostFiber(child); - // $FlowFixMe[incompatible-call] DOM types expect Element + // $FlowFixMe[incompatible-type] DOM types expect Element observer.observe(publicInstance); return false; } @@ -729,8 +732,9 @@ FragmentInstance.prototype.unobserveUsing = function ( } }; function unobserveChild(child: Fiber, observer: IntersectionObserver) { + // $FlowFixMe[incompatible-type] const publicInstance = getPublicInstanceFromHostFiber(child); - // $FlowFixMe[incompatible-call] DOM types expect Element + // $FlowFixMe[incompatible-type] DOM types expect Element observer.unobserve(publicInstance); return false; } @@ -893,8 +897,9 @@ export function commitNewChildToFragmentInstance( if (publicInstance == null) { throw new Error('Expected to find a host node. This is a bug in React.'); } + // $FlowFixMe[incompatible-type] fragmentInstance._observers.forEach(observer => { - // $FlowFixMe[incompatible-call] Element types are behind a flag in RN + // $FlowFixMe[incompatible-type] Element types are behind a flag in RN observer.observe(publicInstance); }); } diff --git a/packages/react-native-renderer/src/ReactFiberConfigFabricWithViewTransition.js b/packages/react-native-renderer/src/ReactFiberConfigFabricWithViewTransition.js index 89aa1ee4c840..10551c9f2937 100644 --- a/packages/react-native-renderer/src/ReactFiberConfigFabricWithViewTransition.js +++ b/packages/react-native-renderer/src/ReactFiberConfigFabricWithViewTransition.js @@ -94,7 +94,7 @@ export function cloneRootViewTransitionContainer( if (__DEV__) { console.warn('cloneRootViewTransitionContainer is not implemented'); } - // $FlowFixMe[incompatible-return] Return empty stub + // $FlowFixMe[incompatible-type] Return empty stub return null; } diff --git a/packages/react-native-renderer/src/ReactNativePublicCompat.js b/packages/react-native-renderer/src/ReactNativePublicCompat.js index 120ddd9e11ca..53f78f734775 100644 --- a/packages/react-native-renderer/src/ReactNativePublicCompat.js +++ b/packages/react-native-renderer/src/ReactNativePublicCompat.js @@ -59,7 +59,7 @@ export function findHostInstance_DEPRECATED( componentOrHandle.canonical && componentOrHandle.canonical.publicInstance ) { - // $FlowExpectedError[incompatible-return] Can't refine componentOrHandle as a Fabric instance + // $FlowExpectedError[incompatible-type] Can't refine componentOrHandle as a Fabric instance return componentOrHandle.canonical.publicInstance; } @@ -75,7 +75,7 @@ export function findHostInstance_DEPRECATED( // findHostInstance handles legacy vs. Fabric differences correctly // $FlowFixMe[incompatible-exact] we need to fix the definition of `HostComponent` to use NativeMethods as an interface, not as a type. - // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] return hostInstance; } @@ -132,11 +132,11 @@ export function findNodeHandle(componentOrHandle: any): ?number { } if (hostInstance == null) { - // $FlowFixMe[incompatible-return] Flow limitation in refining an opaque type + // $FlowFixMe[incompatible-type] Flow limitation in refining an opaque type return hostInstance; } - // $FlowFixMe[incompatible-call] Necessary when running Flow on the legacy renderer + // $FlowFixMe[incompatible-type] Necessary when running Flow on the legacy renderer return getNativeTagFromPublicInstance(hostInstance); } @@ -178,9 +178,9 @@ export function getNodeFromInternalInstanceHandle( internalInstanceHandle: mixed, ): ?Node { return ( - // $FlowExpectedError[incompatible-return] internalInstanceHandle is opaque but we need to make an exception here. + // $FlowExpectedError[incompatible-type] internalInstanceHandle is opaque but we need to make an exception here. internalInstanceHandle && - // $FlowExpectedError[incompatible-return] + // $FlowExpectedError[incompatible-type] internalInstanceHandle.stateNode && // $FlowExpectedError[incompatible-use] internalInstanceHandle.stateNode.node diff --git a/packages/react-native-renderer/src/legacy-events/forEachAccumulated.js b/packages/react-native-renderer/src/legacy-events/forEachAccumulated.js index e9d82b0dd2a2..ef93bbc3189d 100644 --- a/packages/react-native-renderer/src/legacy-events/forEachAccumulated.js +++ b/packages/react-native-renderer/src/legacy-events/forEachAccumulated.js @@ -22,7 +22,7 @@ function forEachAccumulated( scope: ?any, ) { if (Array.isArray(arr)) { - // $FlowFixMe[incompatible-call] if `T` is an array, `cb` cannot be called + // $FlowFixMe[incompatible-type] if `T` is an array, `cb` cannot be called arr.forEach(cb, scope); } else if (arr) { cb.call(scope, arr); diff --git a/packages/react-noop-renderer/src/ReactNoopFlightClient.js b/packages/react-noop-renderer/src/ReactNoopFlightClient.js index cf7e4168bd89..5330906688d9 100644 --- a/packages/react-noop-renderer/src/ReactNoopFlightClient.js +++ b/packages/react-noop-renderer/src/ReactNoopFlightClient.js @@ -27,6 +27,7 @@ const decoderOptions = {stream: true}; const {createResponse, createStreamState, processBinaryChunk, getRoot, close} = // $FlowFixMe[prop-missing] + // $FlowFixMe[incompatible-type] ReactFlightClient({ createStringDecoder() { return new TextDecoder(); @@ -46,7 +47,7 @@ const {createResponse, createStreamState, processBinaryChunk, getRoot, close} = return readModule(idx); }, bindToConsole(methodName, args, badgeName) { - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] return Function.prototype.bind.apply( // eslint-disable-next-line react-internal/no-production-logging console[methodName], @@ -64,10 +65,10 @@ type ReadOptions = {| function read(source: Source, options: ReadOptions): Thenable { const response = createResponse( - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] source, null, - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] null, undefined, undefined, @@ -78,7 +79,7 @@ function read(source: Source, options: ReadOptions): Thenable { true, undefined, __DEV__ && options !== undefined && options.debugChannel !== undefined - ? // $FlowFixMe[incompatible-call] + ? // $FlowFixMe[incompatible-type] options.debugChannel.onMessage : undefined, ); diff --git a/packages/react-noop-renderer/src/ReactNoopFlightServer.js b/packages/react-noop-renderer/src/ReactNoopFlightServer.js index a10edd2b7737..979e72038927 100644 --- a/packages/react-noop-renderer/src/ReactNoopFlightServer.js +++ b/packages/react-noop-renderer/src/ReactNoopFlightServer.js @@ -25,6 +25,7 @@ type Destination = Array; const textEncoder = new TextEncoder(); // $FlowFixMe[prop-missing] +// $FlowFixMe[incompatible-type] const ReactNoopFlightServer = ReactFlightServer({ scheduleMicrotask(callback: () => void) { callback(); @@ -82,7 +83,7 @@ function render(model: ReactClientValue, options?: Options): Destination { const bundlerConfig = undefined; const request = ReactNoopFlightServer.createRequest( model, - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] bundlerConfig, options ? options.onError : undefined, options ? options.identifierPrefix : undefined, @@ -90,7 +91,7 @@ function render(model: ReactClientValue, options?: Options): Destination { options ? options.startTime : undefined, __DEV__ && options ? options.environmentName : undefined, __DEV__ && options ? options.filterStackFrame : undefined, - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] __DEV__ && options && options.debugChannel !== undefined, ); const signal = options ? options.signal : undefined; @@ -113,7 +114,7 @@ function render(model: ReactClientValue, options?: Options): Destination { ReactNoopFlightServer.startWork(request); ReactNoopFlightServer.startFlowing( request, - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] destination, ); return destination; diff --git a/packages/react-noop-renderer/src/ReactNoopServer.js b/packages/react-noop-renderer/src/ReactNoopServer.js index 93f66b27b306..066110a84f66 100644 --- a/packages/react-noop-renderer/src/ReactNoopServer.js +++ b/packages/react-noop-renderer/src/ReactNoopServer.js @@ -80,6 +80,7 @@ function write(destination: Destination, buffer: Uint8Array): void { } // $FlowFixMe[prop-missing] +// $FlowFixMe[incompatible-type] const ReactNoopServer = ReactFizzServer({ scheduleMicrotask(callback: () => void) { callback(); @@ -176,7 +177,7 @@ const ReactNoopServer = ReactFizzServer({ destination: Destination, renderState: RenderState, id: number, - // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] ): boolean { const parent = destination.stack[destination.stack.length - 1]; destination.placeholders.set(id, { @@ -361,6 +362,7 @@ type Options = { function render(children: React$Element, options?: Options): Destination { // $FlowFixMe[prop-missing] + // $FlowFixMe[incompatible-type] const destination: Destination = { root: null, placeholders: new Map(), @@ -371,12 +373,13 @@ function render(children: React$Element, options?: Options): Destination { }, }; const request = ReactNoopServer.createRequest( + // $FlowFixMe[incompatible-type] children, - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] null, - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] null, - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] null, options ? options.progressiveChunkSize : undefined, options ? options.onError : undefined, @@ -384,7 +387,7 @@ function render(children: React$Element, options?: Options): Destination { options ? options.onShellReady : undefined, ); ReactNoopServer.startWork(request); - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] ReactNoopServer.startFlowing(request, destination); return destination; } diff --git a/packages/react-noop-renderer/src/createReactNoop.js b/packages/react-noop-renderer/src/createReactNoop.js index 7172648f997a..877a1ad39c68 100644 --- a/packages/react-noop-renderer/src/createReactNoop.js +++ b/packages/react-noop-renderer/src/createReactNoop.js @@ -126,6 +126,7 @@ function createReactNoop( prevParent !== -1 && prevParent !== // $FlowFixMe[prop-missing] + // $FlowFixMe[incompatible-type] (parentInstance: Instance).id ) { throw new Error('Reparenting is not allowed'); @@ -133,6 +134,7 @@ function createReactNoop( child.parent = // $FlowFixMe[prop-missing] + // $FlowFixMe[incompatible-type] (parentInstance: Instance).id; const index = parentInstance.children.indexOf(child); if (index !== -1) { @@ -699,7 +701,7 @@ function createReactNoop( resetFormInstance(form: Instance) {}, bindToConsole(methodName: $FlowFixMe, args: Array, badgeName: string) { - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] return Function.prototype.bind.apply( // eslint-disable-next-line react-internal/no-production-logging console[methodName], @@ -735,6 +737,7 @@ function createReactNoop( oldProps: Props, newProps: Props, ): void { + // $FlowFixMe[invalid-compare] if (oldProps === null) { throw new Error('Should have old props'); } @@ -1011,7 +1014,9 @@ function createReactNoop( $$typeof: REACT_ELEMENT_TYPE, key: null, props: props, + // $FlowFixMe[constant-condition] _owner: null, + // $FlowFixMe[constant-condition] _store: __DEV__ ? {} : undefined, }; // $FlowFixMe[prop-missing] @@ -1141,8 +1146,10 @@ function createReactNoop( const previousTransition = ReactSharedInternals.T; const preivousEventPriority = currentEventPriority; try { + // $FlowFixMe[constant-condition] ReactSharedInternals.T = null; currentEventPriority = DiscreteEventPriority; + // $FlowFixMe[constant-condition] if (fn) { return fn(); } else { @@ -1164,9 +1171,12 @@ function createReactNoop( } function onDefaultTransitionIndicator(): void | (() => void) {} + // $FlowFixMe[recursive-definition] + // $FlowFixMe[definition-cycle] let idCounter = 0; - // $FlowFixMe + // $FlowFixMe[definition-cycle] + // $FlowFixMe[recursive-definition] const ReactNoop = { _Scheduler: Scheduler, @@ -1220,9 +1230,10 @@ function createReactNoop( root = NoopRenderer.createContainer( // $FlowFixMe[incompatible-call] -- Discovered when typechecking noop-renderer container, + // $FlowFixMe[incompatible-type] tag, null, - // $FlowFixMe[incompatible-call] -- Discovered when typechecking noop-renderer + // $FlowFixMe[incompatible-type] -- Discovered when typechecking noop-renderer null, false, '', @@ -1247,9 +1258,10 @@ function createReactNoop( const fiberRoot = NoopRenderer.createContainer( // $FlowFixMe[incompatible-call] container, + // $FlowFixMe[incompatible-type] ConcurrentRoot, null, - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] null, false, '', @@ -1398,9 +1410,11 @@ function createReactNoop( if (disableLegacyMode) { throw new Error('createLegacyRoot: Unsupported Legacy Mode API.'); } + // $FlowFixMe[incompatible-type] const rootID = DEFAULT_ROOT_ID; const container = ReactNoop.getOrCreateRootContainer(rootID, LegacyRoot); const root = roots.get(container.rootID); + // $FlowFixMe[incompatible-type] NoopRenderer.updateContainer(element, root, null, callback); }, @@ -1411,9 +1425,11 @@ function createReactNoop( ) { const container = ReactNoop.getOrCreateRootContainer( rootID, + // $FlowFixMe[incompatible-type] ConcurrentRoot, ); const root = roots.get(container.rootID); + // $FlowFixMe[incompatible-type] NoopRenderer.updateContainer(element, root, null, callback); }, @@ -1543,8 +1559,9 @@ function createReactNoop( // $FlowFixMe[unsafe-addition] log(indent + '- ' + child.type + '#' + child.id); + // $FlowFixMe[incompatible-type] logHostInstances( - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] child.children, depth + 1, ); @@ -1562,11 +1579,16 @@ function createReactNoop( const update = first; if (update !== null) { do { + // $FlowFixMe[unsafe-addition] + // $FlowFixMe[prop-missing] log( ' '.repeat(depth + 1) + '~', - // $FlowFixMe + // $FlowFixMe[invalid-compare] + // $FlowFixMe[prop-missing] + // $FlowFixMe[unsafe-addition] '[' + update.expirationTime + ']', ); + // $FlowFixMe[invalid-compare] } while (update !== null); } @@ -1575,12 +1597,17 @@ function createReactNoop( const firstPending = lastPending.next; const pendingUpdate = firstPending; if (pendingUpdate !== null) { + // $FlowFixMe[unsafe-addition] + // $FlowFixMe[prop-missing] do { log( + // $FlowFixMe[invalid-compare] ' '.repeat(depth + 1) + '~', - // $FlowFixMe + // $FlowFixMe[prop-missing] + // $FlowFixMe[unsafe-addition] '[' + pendingUpdate.expirationTime + ']', ); + // $FlowFixMe[invalid-compare] } while (pendingUpdate !== null && pendingUpdate !== firstPending); } } @@ -1597,11 +1624,12 @@ function createReactNoop( // $FlowFixMe[prop-missing] fiber.childExpirationTime + (fiber.pendingProps ? '*' : '') + + // $FlowFixMe[incompatible-type] ']', ); if (fiber.updateQueue) { logUpdateQueue( - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] fiber.updateQueue, depth, ); diff --git a/packages/react-reconciler/src/ReactCapturedValue.js b/packages/react-reconciler/src/ReactCapturedValue.js index d53489cc3b72..de48fe6de84f 100644 --- a/packages/react-reconciler/src/ReactCapturedValue.js +++ b/packages/react-reconciler/src/ReactCapturedValue.js @@ -25,6 +25,7 @@ export function createCapturedValueAtFiber( ): CapturedValue { // 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) { @@ -50,7 +51,7 @@ export function createCapturedValueFromError( value: Error, stack: null | string, ): CapturedValue { - const captured = { + const captured: CapturedValue = { value, source: null, stack: stack, diff --git a/packages/react-reconciler/src/ReactChildFiber.js b/packages/react-reconciler/src/ReactChildFiber.js index 42f1b70918d3..d2ad38b15fe0 100644 --- a/packages/react-reconciler/src/ReactChildFiber.js +++ b/packages/react-reconciler/src/ReactChildFiber.js @@ -812,6 +812,7 @@ function createChildReconciler( return created; } + // $FlowFixMe[invalid-compare] if (newChild.$$typeof === REACT_CONTEXT_TYPE) { const context: ReactContext = (newChild: any); return createChild( @@ -953,6 +954,7 @@ function createChildReconciler( return updated; } + // $FlowFixMe[invalid-compare] if (newChild.$$typeof === REACT_CONTEXT_TYPE) { const context: ReactContext = (newChild: any); return updateSlot( @@ -1085,6 +1087,7 @@ function createChildReconciler( return updated; } + // $FlowFixMe[invalid-compare] if (newChild.$$typeof === REACT_CONTEXT_TYPE) { const context: ReactContext = (newChild: any); return updateFromMap( @@ -1983,6 +1986,7 @@ function createChildReconciler( return firstChild; } + // $FlowFixMe[invalid-compare] if (newChild.$$typeof === REACT_CONTEXT_TYPE) { const context: ReactContext = (newChild: any); return reconcileChildFibersImpl( @@ -2225,10 +2229,11 @@ export function validateSuspenseListChildren( enableAsyncIterableChildren && children.$$typeof === REACT_ELEMENT_TYPE && typeof children.type === 'function' && - // $FlowFixMe + // $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/ReactFiber.js b/packages/react-reconciler/src/ReactFiber.js index 7ab798ea22bc..83b12a04a799 100644 --- a/packages/react-reconciler/src/ReactFiber.js +++ b/packages/react-reconciler/src/ReactFiber.js @@ -581,6 +581,7 @@ export function createFiberFromTypeAndProps( } } } else if (typeof type === 'string') { + // $FlowFixMe[constant-condition] if (supportsResources && supportsSingletons) { const hostContext = getHostContext(); fiberTag = isHostHoistableType(type, pendingProps, hostContext) @@ -588,11 +589,13 @@ export function createFiberFromTypeAndProps( : isHostSingletonType(type) ? HostSingleton : HostComponent; + // $FlowFixMe[constant-condition] } else if (supportsResources) { const hostContext = getHostContext(); fiberTag = isHostHoistableType(type, pendingProps, hostContext) ? HostHoistable : HostComponent; + // $FlowFixMe[constant-condition] } else if (supportsSingletons) { fiberTag = isHostSingletonType(type) ? HostSingleton : HostComponent; } else { @@ -600,10 +603,13 @@ export function createFiberFromTypeAndProps( } } else { 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,61 @@ 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] -- falls through case REACT_VIEW_TRANSITION_TYPE: if (enableViewTransition) { return createFiberFromViewTransition(pendingProps, mode, lanes, key); } - // Fall through + // $FlowFixMe[invalid-compare] -- falls through case REACT_SCOPE_TYPE: if (enableScopeAPI) { return createFiberFromScope(type, pendingProps, mode, lanes, key); } - // Fall through + // $FlowFixMe[invalid-compare] -- falls through 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 +685,7 @@ export function createFiberFromTypeAndProps( if ( type === undefined || (typeof type === 'object' && + // $FlowFixMe[invalid-compare] type !== null && Object.keys(type).length === 0) ) { @@ -677,12 +694,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 +718,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 b611d7472b09..9a6fb22c8c0a 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 32e593958457..dd6dcee06d17 100644 --- a/packages/react-reconciler/src/ReactFiberApplyGesture.js +++ b/packages/react-reconciler/src/ReactFiberApplyGesture.js @@ -437,6 +437,7 @@ function recursivelyInsertNewFiber( break; } case HostHoistable: { + // $FlowFixMe[constant-condition] if (supportsResources) { // TODO: Hoistables should get optimistically inserted and then removed. recursivelyInsertNew( @@ -450,6 +451,7 @@ function recursivelyInsertNewFiber( // Fall through } case HostSingleton: { + // $FlowFixMe[constant-condition] if (supportsSingletons) { recursivelyInsertNew( finishedWork, @@ -502,6 +504,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 ' + @@ -643,6 +646,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 ' + @@ -808,6 +812,7 @@ function insertDestinationClonesOfFiber( // to reconciliation, because those can be set on all fiber types. switch (finishedWork.tag) { case HostHoistable: { + // $FlowFixMe[constant-condition] if (supportsResources) { // TODO: Hoistables should get optimistically inserted and then removed. recursivelyInsertClones( @@ -821,6 +826,7 @@ function insertDestinationClonesOfFiber( // Fall through } case HostSingleton: { + // $FlowFixMe[constant-condition] if (supportsSingletons) { recursivelyInsertClones( finishedWork, @@ -916,6 +922,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 ' + @@ -960,6 +967,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); @@ -1307,6 +1315,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 4f41a70e56eb..a05c8a896faa 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.js @@ -1839,6 +1839,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. @@ -1989,6 +1990,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 { @@ -2123,8 +2125,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__) { @@ -2138,6 +2142,7 @@ function mountLazyComponent( props, renderLanes, ); + // $FlowFixMe[invalid-compare] } else if ($$typeof === REACT_MEMO_TYPE) { workInProgress.tag = MemoComponent; return updateMemoComponent( @@ -2147,6 +2152,7 @@ function mountLazyComponent( props, renderLanes, ); + // $FlowFixMe[invalid-compare] } else if ($$typeof === REACT_CONTEXT_TYPE) { workInProgress.tag = ContextProvider; workInProgress.type = Component; @@ -2157,8 +2163,10 @@ function mountLazyComponent( let hint = ''; if (__DEV__) { if ( + // $FlowFixMe[invalid-compare] Component !== null && typeof Component === 'object' && + // $FlowFixMe[invalid-compare] Component.$$typeof === REACT_LAZY_TYPE ) { hint = ' Did you wrap a component in React.lazy() more than once?'; @@ -2275,6 +2283,7 @@ function updateSuspenseOffscreenState( let cachePool: SpawnedCachePool | null = null; const prevCachePool: SpawnedCachePool | null = prevOffscreenState.cachePool; if (prevCachePool !== null) { + // $FlowFixMe[constant-condition] const parentCache = isPrimaryRenderer ? CacheContext._currentValue : CacheContext._currentValue2; @@ -2313,6 +2322,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". @@ -3258,9 +3268,13 @@ function validateRevealOrder(revealOrder: SuspenseListRevealOrder) { didWarnAboutRevealOrder[cacheKey] = true; if (typeof revealOrder === 'string') { switch (revealOrder.toLowerCase()) { + // $FlowFixMe[invalid-compare] case 'together': + // $FlowFixMe[invalid-compare] -- falls through case 'forwards': + // $FlowFixMe[invalid-compare] -- falls through case 'backwards': + // $FlowFixMe[invalid-compare] -- falls through case 'independent': { console.error( '"%s" is not a valid value for revealOrder on . ' + @@ -3270,7 +3284,9 @@ function validateRevealOrder(revealOrder: SuspenseListRevealOrder) { ); break; } + // $FlowFixMe[invalid-compare] case 'forward': + // $FlowFixMe[invalid-compare] -- falls through case 'backward': { console.error( '"%s" is not a valid value for revealOrder on . ' + @@ -3830,6 +3846,7 @@ function remountFiber( newWorkInProgress.return = oldWorkInProgress.return; newWorkInProgress.ref = oldWorkInProgress.ref; + // $FlowFixMe[constant-condition] if (__DEV__) { newWorkInProgress._debugInfo = oldWorkInProgress._debugInfo; } @@ -4297,11 +4314,13 @@ function beginWork( case HostRoot: return updateHostRoot(current, workInProgress, renderLanes); case HostHoistable: + // $FlowFixMe[constant-condition] if (supportsResources) { return updateHostHoistable(current, workInProgress, renderLanes); } // Fall through case HostSingleton: + // $FlowFixMe[constant-condition] if (supportsSingletons) { return updateHostSingleton(current, workInProgress, renderLanes); } diff --git a/packages/react-reconciler/src/ReactFiberClassComponent.js b/packages/react-reconciler/src/ReactFiberClassComponent.js index 1fae90f07b1a..82647990fccd 100644 --- a/packages/react-reconciler/src/ReactFiberClassComponent.js +++ b/packages/react-reconciler/src/ReactFiberClassComponent.js @@ -1070,9 +1070,11 @@ function updateClassInstance( !hasContextChanged() && !checkHasForceUpdateAfterProcessing() && !( - current !== null && - current.dependencies !== null && - checkIfContextChanged(current.dependencies) + // prettier-ignore + // $FlowFixMe[invalid-compare] + (current !== null && + current.dependencies !== null && + checkIfContextChanged(current.dependencies)) ) ) { // If an update was already in progress, we should schedule an Update @@ -1121,6 +1123,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 23bef1e6b098..21c3a6bb372a 100644 --- a/packages/react-reconciler/src/ReactFiberClassUpdateQueue.js +++ b/packages/react-reconciler/src/ReactFiberClassUpdateQueue.js @@ -350,6 +350,7 @@ export function enqueueCapturedUpdate( } 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( 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 f7e20fe92619..1572a65972a6 100644 --- a/packages/react-reconciler/src/ReactFiberCommitEffects.js +++ b/packages/react-reconciler/src/ReactFiberCommitEffects.js @@ -195,11 +195,12 @@ export function commitHookEffectListMount( hookName = 'useEffect'; } let addendum; + // $FlowFixMe[invalid-compare] if (destroy === null) { 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 +925,7 @@ function safelyCallDestroy( ); } else { try { - // $FlowFixMe(incompatible-call) Already bound to resource + // $FlowFixMe[incompatible-type](incompatible-call) Already bound to resource 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/ReactFiberCommitHostEffects.js b/packages/react-reconciler/src/ReactFiberCommitHostEffects.js index 3626561e1b49..043db3fdcacc 100644 --- a/packages/react-reconciler/src/ReactFiberCommitHostEffects.js +++ b/packages/react-reconciler/src/ReactFiberCommitHostEffects.js @@ -311,7 +311,9 @@ function isHostParent(fiber: Fiber): boolean { return ( fiber.tag === HostComponent || fiber.tag === HostRoot || + // $FlowFixMe[constant-condition] (supportsResources ? fiber.tag === HostHoistable : false) || + // $FlowFixMe[constant-condition] (supportsSingletons ? fiber.tag === HostSingleton && isSingletonScope(fiber.type) : false) || @@ -351,6 +353,7 @@ function getHostSibling(fiber: Fiber): ?Instance { // singleton scope. If it is a singleton scope we skip over it because // you only insert against this scope when you are already inside of it if ( + // $FlowFixMe[constant-condition] supportsSingletons && node.tag === HostSingleton && isSingletonScope(node.type) @@ -409,6 +412,7 @@ function insertOrAppendPlacementNodeIntoContainer( } if ( + // $FlowFixMe[constant-condition] (supportsSingletons ? tag === HostSingleton : false) && isSingletonScope(node.type) ) { @@ -467,6 +471,7 @@ function insertOrAppendPlacementNode( } if ( + // $FlowFixMe[constant-condition] (supportsSingletons ? tag === HostSingleton : false) && isSingletonScope(node.type) ) { @@ -512,6 +517,7 @@ function commitPlacement(finishedWork: Fiber): void { parentFiber = parentFiber.return; } + // $FlowFixMe[constant-condition] if (!supportsMutation) { if (enableFragmentRefs) { commitImmutablePlacementNodeToFragmentInstances( @@ -531,6 +537,7 @@ function commitPlacement(finishedWork: Fiber): void { switch (hostParentFiber.tag) { case HostSingleton: { + // $FlowFixMe[constant-condition] if (supportsSingletons) { const parent: Instance = hostParentFiber.stateNode; const before = getHostSibling(finishedWork); diff --git a/packages/react-reconciler/src/ReactFiberCommitViewTransitions.js b/packages/react-reconciler/src/ReactFiberCommitViewTransitions.js index 760270010dbc..d1b72b5a8336 100644 --- a/packages/react-reconciler/src/ReactFiberCommitViewTransitions.js +++ b/packages/react-reconciler/src/ReactFiberCommitViewTransitions.js @@ -140,6 +140,7 @@ function applyViewTransitionToHostInstancesRecursive( collectMeasurements: null | Array, stopAtNestedViewTransitions: boolean, ): boolean { + // $FlowFixMe[constant-condition] if (!supportsMutation) { if (enableViewTransitionForPersistenceMode) { while (child !== null) { @@ -241,6 +242,7 @@ function restoreViewTransitionOnHostInstances( child: null | Fiber, stopAtNestedViewTransitions: boolean, ): void { + // $FlowFixMe[constant-condition] if (!supportsMutation) { return; } @@ -688,6 +690,7 @@ function measureViewTransitionHostInstancesRecursive( previousMeasurements: null | Array, stopAtNestedViewTransitions: boolean, ): boolean { + // $FlowFixMe[constant-condition] if (!supportsMutation) { if (enableViewTransitionForPersistenceMode) { while (child !== null) { diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js index 322c858bb9c0..236952215d77 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.js @@ -487,7 +487,7 @@ function commitBeforeMutationEffectsOnFiber( if ( finishedWork.tag === SuspenseComponent && isSuspenseBoundaryBeingHidden(current, finishedWork) && - // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] found when upgrading Flow doesFiberContain(finishedWork, focusedInstanceHandle) ) { shouldFireAfterActiveInstanceBlur = true; @@ -523,6 +523,7 @@ function commitBeforeMutationEffectsOnFiber( } case HostRoot: { if ((flags & Snapshot) !== NoFlags) { + // $FlowFixMe[constant-condition] if (supportsMutation) { const root = finishedWork.stateNode; clearContainer(root.containerInfo); @@ -652,6 +653,7 @@ function commitLayoutEffectOnFiber( break; } case HostSingleton: { + // $FlowFixMe[constant-condition] if (supportsSingletons) { // We acquire the singleton instance first so it has appropriate // styles before other layout effects run. This isn't perfect because @@ -969,6 +971,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 || @@ -1181,6 +1184,7 @@ function commitTransitionProgress(offscreenFiber: Fiber) { } function hideOrUnhideAllChildren(parentFiber: Fiber, isHidden: boolean) { + // $FlowFixMe[constant-condition] if (!supportsMutation) { return; } @@ -1194,6 +1198,7 @@ function hideOrUnhideAllChildren(parentFiber: Fiber, isHidden: boolean) { } function hideOrUnhideAllChildrenOnFiber(fiber: Fiber, isHidden: boolean) { + // $FlowFixMe[constant-condition] if (!supportsMutation) { return; } @@ -1242,6 +1247,7 @@ function hideOrUnhideAllChildrenOnFiber(fiber: Fiber, isHidden: boolean) { } function hideOrUnhideNearestPortals(parentFiber: Fiber, isHidden: boolean) { + // $FlowFixMe[constant-condition] if (!supportsMutation) { return; } @@ -1255,6 +1261,7 @@ function hideOrUnhideNearestPortals(parentFiber: Fiber, isHidden: boolean) { } function hideOrUnhideNearestPortalsOnFiber(fiber: Fiber, isHidden: boolean) { + // $FlowFixMe[constant-condition] if (!supportsMutation) { return; } @@ -1329,6 +1336,7 @@ function detachFiberAfterEffects(fiber: Fiber) { // one, too. if (fiber.tag === HostComponent) { const hostInstance: Instance = fiber.stateNode; + // $FlowFixMe[invalid-compare] if (hostInstance !== null) { detachDeletedInstance(hostInstance); } @@ -1366,6 +1374,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. @@ -1389,6 +1398,7 @@ function commitDeletionEffects( findParent: while (parent !== null) { switch (parent.tag) { case HostSingleton: { + // $FlowFixMe[constant-condition] if (supportsSingletons) { if (isSingletonScope(parent.type)) { hostParent = parent.stateNode; @@ -1479,6 +1489,7 @@ function commitDeletionEffectsOnFiber( // that don't modify the stack. switch (deletedFiber.tag) { case HostHoistable: { + // $FlowFixMe[constant-condition] if (supportsResources) { if (!offscreenSubtreeWasHidden) { safelyDetachRef(deletedFiber, nearestMountedAncestor); @@ -1498,6 +1509,7 @@ function commitDeletionEffectsOnFiber( // Fall through } case HostSingleton: { + // $FlowFixMe[constant-condition] if (supportsSingletons) { if (!offscreenSubtreeWasHidden) { safelyDetachRef(deletedFiber, nearestMountedAncestor); @@ -1546,6 +1558,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 +1623,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 +1642,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 +1657,7 @@ function commitDeletionEffectsOnFiber( hostParent = prevHostParent; hostParentIsContainer = prevHostParentIsContainer; } else { + // $FlowFixMe[constant-condition] if (supportsPersistence) { commitHostPortalContainerChildren( deletedFiber.stateNode, @@ -1831,6 +1847,7 @@ function commitActivityHydrationCallbacks( finishedRoot: FiberRoot, finishedWork: Fiber, ) { + // $FlowFixMe[constant-condition] if (!supportsHydration) { return; } @@ -1865,6 +1882,7 @@ function commitSuspenseHydrationCallbacks( finishedRoot: FiberRoot, finishedWork: Fiber, ) { + // $FlowFixMe[constant-condition] if (!supportsHydration) { return; } @@ -2099,6 +2117,7 @@ function commitMutationEffectsOnFiber( break; } case HostHoistable: { + // $FlowFixMe[constant-condition] if (supportsResources) { // We cast because we always set the root at the React root and so it cannot be // null while we are processing mutation effects @@ -2177,6 +2196,7 @@ function commitMutationEffectsOnFiber( // Fall through } case HostSingleton: { + // $FlowFixMe[constant-condition] if (supportsSingletons) { recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork, lanes); @@ -2210,6 +2230,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 @@ -2250,6 +2271,7 @@ function commitMutationEffectsOnFiber( } } else { if (enableEagerAlternateStateNodeCleanup) { + // $FlowFixMe[constant-condition] if (supportsPersistence) { if (finishedWork.alternate !== null) { // `finishedWork.alternate.stateNode` is pointing to a stale shadow @@ -2270,6 +2292,7 @@ function commitMutationEffectsOnFiber( commitReconciliationEffects(finishedWork, lanes); if (flags & Update) { + // $FlowFixMe[constant-condition] if (supportsMutation) { if (finishedWork.stateNode === null) { throw new Error( @@ -2294,6 +2317,7 @@ function commitMutationEffectsOnFiber( const prevProfilerEffectDuration = pushNestedEffectDurations(); pushRootMutationContext(); + // $FlowFixMe[constant-condition] if (supportsResources) { prepareToCommitHoistables(); @@ -2310,6 +2334,7 @@ function commitMutationEffectsOnFiber( } if (flags & Update) { + // $FlowFixMe[constant-condition] if (supportsMutation && supportsHydration) { if (current !== null) { const prevRootState: RootState = current.memoizedState; @@ -2318,6 +2343,7 @@ function commitMutationEffectsOnFiber( } } } + // $FlowFixMe[constant-condition] if (supportsPersistence) { commitHostRootContainerChildren(root, finishedWork); } @@ -2368,6 +2394,7 @@ function commitMutationEffectsOnFiber( const prevOffscreenDirectParentIsHidden = offscreenDirectParentIsHidden; offscreenDirectParentIsHidden = offscreenSubtreeIsHidden; const prevMutationContext = pushMutationContext(); + // $FlowFixMe[constant-condition] if (supportsResources) { const previousHoistableRoot = currentHoistableRoot; currentHoistableRoot = getHoistableRoot( @@ -2391,6 +2418,7 @@ function commitMutationEffectsOnFiber( offscreenDirectParentIsHidden = prevOffscreenDirectParentIsHidden; if (flags & Update) { + // $FlowFixMe[constant-condition] if (supportsPersistence) { commitHostPortalContainerChildren( finishedWork.stateNode, @@ -2577,6 +2605,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) { @@ -2623,6 +2652,7 @@ function commitMutationEffectsOnFiber( const prevMutationContext = pushMutationContext(); const prevUpdate = inUpdateViewTransition; const isViewTransitionEligible = + // $FlowFixMe[constant-condition] enableViewTransition && includesOnlyViewTransitionEligibleLanes(lanes); const props = finishedWork.memoizedProps; @@ -3016,6 +3046,7 @@ export function disappearLayoutEffects(finishedWork: Fiber) { break; } case HostSingleton: { + // $FlowFixMe[constant-condition] if (supportsSingletons) { // TODO (Offscreen) Check: flags & RefStatic commitHostSingletonRelease(finishedWork); @@ -3160,6 +3191,7 @@ export function reappearLayoutEffects( // ... // } case HostSingleton: { + // $FlowFixMe[constant-condition] if (supportsSingletons) { // We acquire the singleton instance first so it has appropriate // styles before other layout effects run. This isn't perfect because @@ -3261,6 +3293,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. @@ -3398,6 +3431,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) { @@ -3712,6 +3746,7 @@ function commitPassiveMountOnFiber( } if (isViewTransitionEligible) { + // $FlowFixMe[constant-condition] if (supportsMutation && rootViewTransitionNameCanceled) { restoreRootViewTransitionName(finishedRoot.containerInfo); } @@ -4687,6 +4722,7 @@ function accumulateSuspenseyCommitOnFiber( } case HostRoot: case HostPortal: { + // $FlowFixMe[constant-condition] if (supportsResources) { const previousHoistableRoot = currentHoistableRoot; const container: Container = fiber.stateNode.containerInfo; diff --git a/packages/react-reconciler/src/ReactFiberCompleteWork.js b/packages/react-reconciler/src/ReactFiberCompleteWork.js index 6fc4297e1b33..0e9b762a6d87 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. @@ -254,6 +256,7 @@ function appendAllChildren( appendInitialChild(parent, node.stateNode); } else if ( node.tag === HostPortal || + // $FlowFixMe[constant-condition] (supportsSingletons ? node.tag === HostSingleton : false) ) { // If we have a portal child, then we don't want to traverse @@ -280,6 +283,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 +361,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 +433,7 @@ function appendAllChildrenToContainer( } function updateHostContainer(current: null | Fiber, workInProgress: Fiber) { + // $FlowFixMe[constant-condition] if (supportsPersistence) { if (doesRequireClone(current, workInProgress)) { const portalOrRoot: { @@ -459,6 +465,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 +477,7 @@ function updateHostComponent( } markUpdate(workInProgress); + // $FlowFixMe[constant-condition] } else if (supportsPersistence) { const currentInstance = current.stateNode; const oldProps = current.memoizedProps; @@ -667,11 +675,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 +932,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. @@ -1184,6 +1196,7 @@ function completeWork( return null; } case HostHoistable: { + // $FlowFixMe[constant-condition] if (supportsResources) { // The branching here is more complicated than you might expect because // a HostHoistable sometimes corresponds to a Resource and sometimes @@ -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); @@ -1284,11 +1298,13 @@ function completeWork( // Fall through } case HostSingleton: { + // $FlowFixMe[constant-condition] if (supportsSingletons) { popHostContext(workInProgress); 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 f8c67a1c3fed..998b797270af 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/ReactFiberGestureScheduler.js b/packages/react-reconciler/src/ReactFiberGestureScheduler.js index 373e8167cab7..797f17bb90d0 100644 --- a/packages/react-reconciler/src/ReactFiberGestureScheduler.js +++ b/packages/react-reconciler/src/ReactFiberGestureScheduler.js @@ -53,6 +53,7 @@ export function scheduleGesture( return prev; } const next = prev.next; + // $FlowFixMe[invalid-compare] if (next === null) { break; } @@ -119,6 +120,7 @@ export function startScheduledGesture( return prev; } const next = prev.next; + // $FlowFixMe[invalid-compare] if (next === null) { break; } diff --git a/packages/react-reconciler/src/ReactFiberHooks.js b/packages/react-reconciler/src/ReactFiberHooks.js index 29c83c7d7263..716399b728ed 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.js +++ b/packages/react-reconciler/src/ReactFiberHooks.js @@ -415,9 +415,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) { @@ -1148,6 +1148,7 @@ function useThenable(thenable: Thenable): T { } function use(usable: Usable): T { + // $FlowFixMe[invalid-compare] if (usable !== null && typeof usable === 'object') { // $FlowFixMe[method-unbinding] if (typeof usable.then === 'function') { @@ -1526,6 +1527,7 @@ function updateReducerImpl( } } update = update.next; + // $FlowFixMe[invalid-compare] } while (update !== null && update !== first); if (newBaseQueueLast === null) { @@ -2472,6 +2474,7 @@ function updateActionStateImpl( let state: Awaited; if ( typeof actionResult === 'object' && + // $FlowFixMe[invalid-compare] actionResult !== null && // $FlowFixMe[method-unbinding] typeof actionResult.then === 'function' @@ -2645,7 +2648,7 @@ function updateEffectImpl( if (nextDeps !== null) { const prevEffect: Effect = currentHook.memoizedState; const prevDeps = prevEffect.deps; - // $FlowFixMe[incompatible-call] (@poteto) + // $FlowFixMe[incompatible-type] (@poteto) if (areHookInputsEqual(nextDeps, prevDeps)) { hook.memoizedState = pushSimpleEffect( hookFlags, @@ -2725,7 +2728,7 @@ function mountEvent) => Return>( const hook = mountWorkInProgressHook(); const ref = {impl: callback}; hook.memoizedState = ref; - // $FlowIgnore[incompatible-return] + // $FlowFixMe[incompatible-type] return function eventFn() { if (isInvalidExecutionContextForEventFunction()) { throw new Error( @@ -2742,7 +2745,7 @@ function updateEvent) => Return>( const hook = updateWorkInProgressHook(); const ref = hook.memoizedState; useEffectEventImpl({ref, nextImpl: callback}); - // $FlowIgnore[incompatible-return] + // $FlowFixMe[incompatible-type] return function eventFn() { if (isInvalidExecutionContextForEventFunction()) { throw new Error( @@ -2833,6 +2836,7 @@ function mountImperativeHandle( 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', ); } @@ -2867,6 +2871,7 @@ function updateImperativeHandle( 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 2d2ec4c88acd..5b8be7008a22 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 0c758202b52f..9544a47e7333 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; } @@ -182,6 +183,7 @@ function reenterHydrationStateFromDehydratedActivityInstance( activityInstance: ActivityInstance, treeContext: TreeContext | null, ): boolean { + // $FlowFixMe[constant-condition] if (!supportsHydration) { return false; } @@ -204,6 +206,7 @@ function reenterHydrationStateFromDehydratedSuspenseInstance( suspenseInstance: SuspenseInstance, treeContext: TreeContext | null, ): boolean { + // $FlowFixMe[constant-condition] if (!supportsHydration) { return false; } @@ -257,6 +260,8 @@ function tryHydrateInstance( fiber.pendingProps, rootOrSingletonContext, ); + // $FlowFixMe[invalid-compare] + // $FlowFixMe[invalid-compare] if (instance !== null) { fiber.stateNode = (instance: Instance); @@ -267,7 +272,9 @@ function tryHydrateInstance( fiber.type, fiber.pendingProps, hostContext, + // $FlowFixMe[invalid-compare] ); + // $FlowFixMe[invalid-compare] if (differences !== null) { const diffNode = buildHydrationDiffNode(fiber, 0); diffNode.serverProps = differences; @@ -289,8 +296,10 @@ function tryHydrateText(fiber: Fiber, nextInstance: any) { const textInstance = canHydrateTextInstance( nextInstance, text, + // $FlowFixMe[invalid-compare] rootOrSingletonContext, ); + // $FlowFixMe[invalid-compare] if (textInstance !== null) { fiber.stateNode = (textInstance: TextInstance); hydrationParentFiber = fiber; @@ -307,9 +316,11 @@ function tryHydrateActivity( ): null | ActivityInstance { // fiber is a ActivityComponent Fiber const activityInstance = canHydrateActivityInstance( + // $FlowFixMe[invalid-compare] nextInstance, rootOrSingletonContext, ); + // $FlowFixMe[invalid-compare] if (activityInstance !== null) { const activityState: ActivityState = { dehydrated: activityInstance, @@ -339,10 +350,12 @@ function tryHydrateSuspense( nextInstance: any, ): null | SuspenseInstance { // fiber is a SuspenseComponent Fiber + // $FlowFixMe[invalid-compare] const suspenseInstance = canHydrateSuspenseInstance( nextInstance, rootOrSingletonContext, ); + // $FlowFixMe[invalid-compare] if (suspenseInstance !== null) { const suspenseState: SuspenseState = { dehydrated: suspenseInstance, @@ -403,6 +416,7 @@ function throwOnHydrationMismatch(fiber: Fiber, fromText: boolean = false) { } function claimHydratableSingleton(fiber: Fiber): void { + // $FlowFixMe[constant-condition] if (supportsSingletons) { if (!isHydrating) { return; @@ -420,11 +434,13 @@ function claimHydratableSingleton(fiber: Fiber): void { if (__DEV__) { if (!didSuspendOrErrorDEV) { const differences = diffHydratedPropsForDevWarnings( + // $FlowFixMe[invalid-compare] instance, fiber.type, fiber.pendingProps, currentHostContext, ); + // $FlowFixMe[invalid-compare] if (differences !== null) { const diffNode = buildHydrationDiffNode(fiber, 0); diffNode.serverProps = differences; @@ -543,6 +559,7 @@ function prepareToHydrateHostInstance( fiber: Fiber, hostContext: HostContext, ): void { + // $FlowFixMe[constant-condition] if (!supportsHydration) { throw new Error( 'Expected prepareToHydrateHostInstance() to never be called. ' + @@ -564,6 +581,7 @@ function prepareToHydrateHostInstance( } function prepareToHydrateHostTextInstance(fiber: Fiber): void { + // $FlowFixMe[constant-condition] if (!supportsHydration) { throw new Error( 'Expected prepareToHydrateHostTextInstance() to never be called. ' + @@ -582,12 +600,14 @@ function prepareToHydrateHostTextInstance(fiber: Fiber): void { switch (returnFiber.tag) { case HostRoot: { if (__DEV__) { + // $FlowFixMe[invalid-compare] if (shouldWarnIfMismatchDev) { const difference = diffHydratedTextForDevWarnings( textInstance, textContent, parentProps, ); + // $FlowFixMe[invalid-compare] if (difference !== null) { const diffNode = buildHydrationDiffNode(fiber, 0); diffNode.serverProps = difference; @@ -599,6 +619,7 @@ function prepareToHydrateHostTextInstance(fiber: Fiber): void { case HostSingleton: case HostComponent: { parentProps = returnFiber.memoizedProps; + // $FlowFixMe[invalid-compare] if (__DEV__) { if (shouldWarnIfMismatchDev) { const difference = diffHydratedTextForDevWarnings( @@ -606,6 +627,7 @@ function prepareToHydrateHostTextInstance(fiber: Fiber): void { textContent, parentProps, ); + // $FlowFixMe[invalid-compare] if (difference !== null) { const diffNode = buildHydrationDiffNode(fiber, 0); diffNode.serverProps = difference; @@ -630,6 +652,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. ' + @@ -651,6 +674,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. ' + @@ -692,6 +716,7 @@ function skipPastDehydratedActivityInstance( function skipPastDehydratedSuspenseInstance( fiber: Fiber, ): null | HydratableInstance { + // $FlowFixMe[constant-condition] if (!supportsHydration) { throw new Error( 'Expected skipPastDehydratedSuspenseInstance() to never be called. ' + @@ -732,6 +757,7 @@ function popToNextHostParent(fiber: Fiber): void { } function popHydrationState(fiber: Fiber): boolean { + // $FlowFixMe[constant-condition] if (!supportsHydration) { return false; } @@ -751,6 +777,7 @@ function popHydrationState(fiber: Fiber): boolean { const tag = fiber.tag; + // $FlowFixMe[constant-condition] if (supportsSingletons) { // With float we never clear the Root, or Singleton instances. We also do not clear Instances // that have singleton text content @@ -792,6 +819,7 @@ function popHydrationState(fiber: Fiber): boolean { nextHydratableInstance = skipPastDehydratedSuspenseInstance(fiber); } else if (tag === ActivityComponent) { nextHydratableInstance = skipPastDehydratedActivityInstance(fiber); + // $FlowFixMe[constant-condition] } else if (supportsSingletons && tag === HostSingleton) { nextHydratableInstance = getNextHydratableSiblingAfterSingleton( fiber.type, @@ -805,6 +833,7 @@ function popHydrationState(fiber: Fiber): boolean { return true; } +// $FlowFixMe[invalid-compare] function warnIfUnhydratedTailNodes(fiber: Fiber) { if (__DEV__) { let nextInstance = nextHydratableInstance; @@ -813,6 +842,7 @@ function warnIfUnhydratedTailNodes(fiber: Fiber) { const description = describeHydratableInstanceForDevWarnings(nextInstance); diffNode.serverTail.push(description); + // $FlowFixMe[invalid-compare] if (description.type === 'Suspense') { const suspenseInstance: SuspenseInstance = (nextInstance: any); nextInstance = @@ -825,6 +855,7 @@ function warnIfUnhydratedTailNodes(fiber: Fiber) { } function resetHydrationState(): void { + // $FlowFixMe[constant-condition] if (!supportsHydration) { return; } @@ -845,6 +876,7 @@ function resetHydrationState(): void { // before re-running beginWork on the same fiber, or when throwAndUnwindWorkLoop // calls unwindWork on ancestor fibers. function popHydrationStateOnInterruptedWork(fiber: Fiber): void { + // $FlowFixMe[constant-condition] if (!supportsHydration) { return; } diff --git a/packages/react-reconciler/src/ReactFiberLane.js b/packages/react-reconciler/src/ReactFiberLane.js index 987f0338ad1a..19c873e70fc6 100644 --- a/packages/react-reconciler/src/ReactFiberLane.js +++ b/packages/react-reconciler/src/ReactFiberLane.js @@ -942,6 +942,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 ac9d766d6ae3..354f849e40e2 100644 --- a/packages/react-reconciler/src/ReactFiberNewContext.js +++ b/packages/react-reconciler/src/ReactFiberNewContext.js @@ -84,6 +84,7 @@ export function pushProvider( context: ReactContext, nextValue: T, ): void { + // $FlowFixMe[constant-condition] if (isPrimaryRenderer) { push(valueCursor, context._currentValue, providerFiber); @@ -131,6 +132,7 @@ export function popProvider( ): void { const currentValue = valueCursor.current; + // $FlowFixMe[constant-condition] if (isPrimaryRenderer) { context._currentValue = currentValue; if (__DEV__) { @@ -236,6 +238,7 @@ function propagateContextChanges( findContext: for (let i = 0; i < contexts.length; i++) { const context: ReactContext = contexts[i]; // Check if the context matches. + // $FlowFixMe[invalid-compare] if (dependency.context === context) { // Match! Schedule an update on this fiber. @@ -520,6 +523,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; @@ -577,6 +581,7 @@ function readContextForConsumer( consumer: Fiber | null, context: ReactContext, ): T { + // $FlowFixMe[constant-condition] const value = isPrimaryRenderer ? context._currentValue : context._currentValue2; @@ -598,20 +603,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 a1a2d76cecc0..877d0cd20c7e 100644 --- a/packages/react-reconciler/src/ReactFiberPerformanceTrack.js +++ b/packages/react-reconciler/src/ReactFiberPerformanceTrack.js @@ -511,6 +511,7 @@ function logComponentEffectErrored( performance.measure.bind(performance, measureName, options), ); } else { + // $FlowFixMe[incompatible-type] performance.measure(measureName, options); } performance.clearMeasures(measureName); @@ -783,6 +784,7 @@ export function logBlockingStart( performance.measure.bind(performance, label, measureOptions), ); } else { + // $FlowFixMe[incompatible-type] performance.measure(label, measureOptions); } performance.clearMeasures(label); @@ -889,6 +891,7 @@ export function logGestureStart( performance.measure.bind(performance, label, measureOptions), ); } else { + // $FlowFixMe[incompatible-type] performance.measure(label, measureOptions); } performance.clearMeasures(label); @@ -1030,6 +1033,7 @@ export function logTransitionStart( performance.measure.bind(performance, label, measureOptions), ); } else { + // $FlowFixMe[incompatible-type] performance.measure(label, measureOptions); } performance.clearMeasures(label); diff --git a/packages/react-reconciler/src/ReactFiberReconciler.js b/packages/react-reconciler/src/ReactFiberReconciler.js index 4a36b39c43c8..596c54673fe9 100644 --- a/packages/react-reconciler/src/ReactFiberReconciler.js +++ b/packages/react-reconciler/src/ReactFiberReconciler.js @@ -880,6 +880,7 @@ export function injectIntoDevTools(): boolean { // which may not match for third party renderers. reconcilerVersion: ReactVersion, }; + // $FlowFixMe[invalid-compare] if (extraDevToolsConfig !== null) { internals.rendererConfig = (extraDevToolsConfig: RendererInspectionConfig); } diff --git a/packages/react-reconciler/src/ReactFiberRootScheduler.js b/packages/react-reconciler/src/ReactFiberRootScheduler.js index 26b625522762..cc97e21d54cb 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 8f9f1cdea577..2fa915d8fa92 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; } @@ -145,11 +147,13 @@ function DO_NOT_USE_queryAllNodes( fn: ReactScopeQuery, ): null | Array { const currentFiber = getInstanceFromScope(this); + // $FlowFixMe[invalid-compare] if (currentFiber === null) { return null; } const child = currentFiber.child; const scopedNodes: Array = []; + // $FlowFixMe[invalid-compare] if (child !== null) { collectScopedNodesFromChildren(child, fn, scopedNodes); } @@ -161,10 +165,12 @@ function DO_NOT_USE_queryFirstNode( fn: ReactScopeQuery, ): null | Object { const currentFiber = getInstanceFromScope(this); + // $FlowFixMe[invalid-compare] if (currentFiber === null) { return null; } const child = currentFiber.child; + // $FlowFixMe[invalid-compare] if (child !== null) { return collectFirstScopedNodeFromChildren(child, fn); } @@ -187,11 +193,13 @@ function getChildContextValues( context: ReactContext, ): Array { const currentFiber = getInstanceFromScope(this); + // $FlowFixMe[invalid-compare] if (currentFiber === null) { return []; } const child = currentFiber.child; const childContextValues: Array = []; + // $FlowFixMe[invalid-compare] if (child !== null) { collectNearestChildContextValues(child, context, childContextValues); } diff --git a/packages/react-reconciler/src/ReactFiberSuspenseComponent.js b/packages/react-reconciler/src/ReactFiberSuspenseComponent.js index 695c36971546..dea7812a0354 100644 --- a/packages/react-reconciler/src/ReactFiberSuspenseComponent.js +++ b/packages/react-reconciler/src/ReactFiberSuspenseComponent.js @@ -62,6 +62,7 @@ export type RetryQueue = Set; 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 aec47af4656e..3abea66ba606 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/ReactFiberThenable.js b/packages/react-reconciler/src/ReactFiberThenable.js index b8b6c5d4b852..3da3120c061a 100644 --- a/packages/react-reconciler/src/ReactFiberThenable.js +++ b/packages/react-reconciler/src/ReactFiberThenable.js @@ -308,6 +308,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-reconciler/src/ReactFiberTracingMarkerComponent.js b/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.js index a54025294bb5..8fbf5aefd3dd 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 180a09b3659f..a4d4190d0d49 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 d45a2d18cf93..533cc43675c8 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js @@ -1321,7 +1321,9 @@ function recoverFromConcurrentError( // Before rendering again, save the errors from the previous attempt. const errorsFromFirstAttempt = workInProgressRootConcurrentErrors; + // $FlowFixMe[constant-condition] const wasRootDehydrated = supportsHydration && isRootDehydrated(root); + // $FlowFixMe[constant-condition] if (wasRootDehydrated) { // The shell failed to hydrate. Set a flag to force a client rendering // during the next attempt. To do this, we call prepareFreshStack now @@ -3042,7 +3044,7 @@ function workLoopConcurrent(nonIdle: boolean) { if (workInProgress !== null) { const yieldAfter = now() + (nonIdle ? 25 : 5); do { - // $FlowFixMe[incompatible-call] flow doesn't know that now() is side-effect free + // $FlowFixMe[incompatible-type] flow doesn't know that now() is side-effect free performUnitOfWork(workInProgress); } while (workInProgress !== null && now() < yieldAfter); } @@ -3052,7 +3054,7 @@ function workLoopConcurrent(nonIdle: boolean) { 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] flow doesn't know that shouldYield() is side-effect free performUnitOfWork(workInProgress); } } @@ -4371,6 +4373,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 ec30b2112b21..b200c8ec6f82 100644 --- a/packages/react-reconciler/src/ReactTestSelectors.js +++ b/packages/react-reconciler/src/ReactTestSelectors.js @@ -130,6 +130,7 @@ function findFiberRootForHostRoot(hostRoot: Instance): Fiber { } else { const fiberRoot = findFiberRoot(hostRoot); + // $FlowFixMe[invalid-compare] if (fiberRoot === null) { throw new Error( 'Could not find React container within specified host subtree.', @@ -177,7 +178,9 @@ function matchSelector(fiber: Fiber, selector: Selector): boolean { tag === HostSingleton ) { const textContent = getTextContent(fiber); + // $FlowFixMe[invalid-compare] if ( + // $FlowFixMe[invalid-compare] textContent !== null && textContent.indexOf(((selector: any): TextSelector).value) >= 0 ) { @@ -307,6 +310,7 @@ export function findAllNodes( hostRoot: Instance, selectors: Array, ): Array { + // $FlowFixMe[constant-condition] if (!supportsTestSelectors) { throw new Error('Test selector API is not supported by this renderer.'); } @@ -346,6 +350,7 @@ export function getFindAllNodesFailureDescription( hostRoot: Instance, selectors: Array, ): string | null { + // $FlowFixMe[constant-condition] if (!supportsTestSelectors) { throw new Error('Test selector API is not supported by this renderer.'); } @@ -417,6 +422,7 @@ export function findBoundingRects( hostRoot: Instance, selectors: Array, ): Array { + // $FlowFixMe[constant-condition] if (!supportsTestSelectors) { throw new Error('Test selector API is not supported by this renderer.'); } @@ -507,6 +513,7 @@ export function focusWithin( hostRoot: Instance, selectors: Array, ): boolean { + // $FlowFixMe[constant-condition] if (!supportsTestSelectors) { throw new Error('Test selector API is not supported by this renderer.'); } @@ -545,6 +552,7 @@ export function focusWithin( const commitHooks: Array = []; export function onCommitRoot(): void { + // $FlowFixMe[constant-condition] if (supportsTestSelectors) { commitHooks.forEach(commitHook => commitHook()); } @@ -562,6 +570,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-dom-esm/src/ReactFlightESMNodeLoader.js b/packages/react-server-dom-esm/src/ReactFlightESMNodeLoader.js index 450f1b25d022..258993e59c62 100644 --- a/packages/react-server-dom-esm/src/ReactFlightESMNodeLoader.js +++ b/packages/react-server-dom-esm/src/ReactFlightESMNodeLoader.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,7 @@ async function transformModuleIfNeeded( const sourceMapString = typeof sourceMapResult.source === 'string' ? sourceMapResult.source - : // $FlowFixMe + : // $FlowFixMe[extra-arg] sourceMapResult.source.toString('utf8'); sourceMap = JSON.parse(sourceMapString); diff --git a/packages/react-server-dom-esm/src/ReactFlightESMReferences.js b/packages/react-server-dom-esm/src/ReactFlightESMReferences.js index 8ad9f222faf7..98c9eeb717d0 100644 --- a/packages/react-server-dom-esm/src/ReactFlightESMReferences.js +++ b/packages/react-server-dom-esm/src/ReactFlightESMReferences.js @@ -49,7 +49,7 @@ const FunctionBind = Function.prototype.bind; // $FlowFixMe[method-unbinding] 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-esm/src/client/ReactFlightClientConfigBundlerESM.js b/packages/react-server-dom-esm/src/client/ReactFlightClientConfigBundlerESM.js index ebd281298331..0d0836141e5a 100644 --- a/packages/react-server-dom-esm/src/client/ReactFlightClientConfigBundlerESM.js +++ b/packages/react-server-dom-esm/src/client/ReactFlightClientConfigBundlerESM.js @@ -139,7 +139,7 @@ export function getModuleDebugInfo( if (ioInfo === undefined) { let href; try { - // $FlowFixMe + // $FlowFixMe[incompatible-type] href = new URL(filename, document.baseURI).href; } catch (_) { href = filename; @@ -162,10 +162,10 @@ export function getModuleDebugInfo( } } const value = Promise.resolve(href); - // $FlowFixMe + // $FlowFixMe[prop-missing] value.status = 'fulfilled'; // Is there some more useful representation for the chunk? - // $FlowFixMe + // $FlowFixMe[prop-missing] value.value = href; // Create a fake stack frame that points to the beginning of the chunk. This is // probably not source mapped so will link to the compiled source rather than diff --git a/packages/react-server-dom-esm/src/server/ReactFlightDOMServerNode.js b/packages/react-server-dom-esm/src/server/ReactFlightDOMServerNode.js index 0224bb382bfa..1b4330207b85 100644 --- a/packages/react-server-dom-esm/src/server/ReactFlightDOMServerNode.js +++ b/packages/react-server-dom-esm/src/server/ReactFlightDOMServerNode.js @@ -124,11 +124,11 @@ function startReadingFromDebugChannelReadable( const ws: WebSocket = (stream: any); ws.binaryType = 'arraybuffer'; ws.addEventListener('message', event => { - // $FlowFixMe + // $FlowFixMe[incompatible-type] onData(event.data); }); ws.addEventListener('error', event => { - // $FlowFixMe + // $FlowFixMe[prop-missing] onError(event.error); }); ws.addEventListener('close', onClose); @@ -468,7 +468,7 @@ function decodeReplyFromBusboy( busboyStream.on('error', err => { reportGlobalError( response, - // $FlowFixMe[incompatible-call] types Error and mixed are incompatible + // $FlowFixMe[incompatible-type] types Error and mixed are incompatible err, ); }); diff --git a/packages/react-server-dom-fb/src/ReactDOMServerFB.js b/packages/react-server-dom-fb/src/ReactDOMServerFB.js index b610a00566ca..6412229232f9 100644 --- a/packages/react-server-dom-fb/src/ReactDOMServerFB.js +++ b/packages/react-server-dom-fb/src/ReactDOMServerFB.js @@ -44,7 +44,7 @@ opaque type Stream = { }; function renderToStream(children: ReactNodeList, options: Options): Stream { - const destination = { + const destination: Destination = { buffer: '', done: false, fatal: false, diff --git a/packages/react-server-dom-parcel/src/ReactFlightParcelReferences.js b/packages/react-server-dom-parcel/src/ReactFlightParcelReferences.js index 3dd67e733cee..84051cfbd5dc 100644 --- a/packages/react-server-dom-parcel/src/ReactFlightParcelReferences.js +++ b/packages/react-server-dom-parcel/src/ReactFlightParcelReferences.js @@ -56,7 +56,7 @@ const FunctionBind = Function.prototype.bind; // $FlowFixMe[method-unbinding] 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-parcel/src/server/ReactFlightDOMServerBrowser.js b/packages/react-server-dom-parcel/src/server/ReactFlightDOMServerBrowser.js index aa677216d0a0..e21620455d92 100644 --- a/packages/react-server-dom-parcel/src/server/ReactFlightDOMServerBrowser.js +++ b/packages/react-server-dom-parcel/src/server/ReactFlightDOMServerBrowser.js @@ -156,6 +156,7 @@ export function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); debugStream.pipeTo(debugChannelWritable); @@ -178,6 +179,7 @@ export function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); return stream; @@ -206,6 +208,7 @@ export function prerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); resolve({prelude: stream}); diff --git a/packages/react-server-dom-parcel/src/server/ReactFlightDOMServerEdge.js b/packages/react-server-dom-parcel/src/server/ReactFlightDOMServerEdge.js index 18813139526f..b8f4429bb6ae 100644 --- a/packages/react-server-dom-parcel/src/server/ReactFlightDOMServerEdge.js +++ b/packages/react-server-dom-parcel/src/server/ReactFlightDOMServerEdge.js @@ -161,6 +161,7 @@ export function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); debugStream.pipeTo(debugChannelWritable); @@ -183,6 +184,7 @@ export function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); return stream; @@ -211,6 +213,7 @@ export function prerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); resolve({prelude: stream}); @@ -310,7 +313,7 @@ export 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[prop-missing] should be able to pass mixed iterator.throw(reason).then(error, error); } } diff --git a/packages/react-server-dom-parcel/src/server/ReactFlightDOMServerNode.js b/packages/react-server-dom-parcel/src/server/ReactFlightDOMServerNode.js index d39081aecfef..7beb11dc9ff1 100644 --- a/packages/react-server-dom-parcel/src/server/ReactFlightDOMServerNode.js +++ b/packages/react-server-dom-parcel/src/server/ReactFlightDOMServerNode.js @@ -137,11 +137,11 @@ function startReadingFromDebugChannelReadable( const ws: WebSocket = (stream: any); ws.binaryType = 'arraybuffer'; ws.addEventListener('message', event => { - // $FlowFixMe + // $FlowFixMe[incompatible-type] onData(event.data); }); ws.addEventListener('error', event => { - // $FlowFixMe + // $FlowFixMe[prop-missing] onError(event.error); }); ws.addEventListener('close', onClose); @@ -386,6 +386,7 @@ export function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); debugStream.pipeTo(debugChannelWritable); @@ -410,6 +411,7 @@ export function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); return stream; @@ -520,6 +522,7 @@ export function prerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); resolve({prelude: stream}); @@ -698,7 +701,7 @@ export function decodeReplyFromBusboy( busboyStream.on('error', err => { reportGlobalError( response, - // $FlowFixMe[incompatible-call] types Error and mixed are incompatible + // $FlowFixMe[incompatible-type] types Error and mixed are incompatible err, ); }); @@ -768,7 +771,7 @@ export 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[prop-missing] should be able to pass mixed iterator.throw(reason).then(error, error); } } diff --git a/packages/react-server-dom-turbopack/src/ReactFlightTurbopackReferences.js b/packages/react-server-dom-turbopack/src/ReactFlightTurbopackReferences.js index 50f83d31d8b1..86fc63d72246 100644 --- a/packages/react-server-dom-turbopack/src/ReactFlightTurbopackReferences.js +++ b/packages/react-server-dom-turbopack/src/ReactFlightTurbopackReferences.js @@ -63,7 +63,7 @@ const FunctionBind = Function.prototype.bind; // $FlowFixMe[method-unbinding] 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__) { @@ -261,6 +261,8 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe { const clientReference: ClientReference = registerClientReferenceImpl(({}: any), target.$$id, true); + // $FlowFixMe[incompatible-variance] + // $FlowFixMe[incompatible-type] const proxy = new Proxy(clientReference, proxyHandlers); // Treat this as a resolved Promise for React's use() @@ -355,5 +357,8 @@ export function createClientModuleProxy( moduleId, false, ); + // $FlowFixMe[incompatible-variance] + // $FlowFixMe[incompatible-type] + // $FlowFixMe[incompatible-exact] return new Proxy(clientReference, proxyHandlers); } diff --git a/packages/react-server-dom-turbopack/src/client/ReactFlightClientConfigBundlerTurbopackBrowser.js b/packages/react-server-dom-turbopack/src/client/ReactFlightClientConfigBundlerTurbopackBrowser.js index b00fe3cb06f0..7ea71747a8d6 100644 --- a/packages/react-server-dom-turbopack/src/client/ReactFlightClientConfigBundlerTurbopackBrowser.js +++ b/packages/react-server-dom-turbopack/src/client/ReactFlightClientConfigBundlerTurbopackBrowser.js @@ -33,7 +33,7 @@ export function addChunkDebugInfo( if (ioInfo === undefined) { let href; try { - // $FlowFixMe + // $FlowFixMe[incompatible-type] href = new URL(filename, document.baseURI).href; } catch (_) { href = filename; @@ -56,10 +56,10 @@ export function addChunkDebugInfo( } } const value = Promise.resolve(href); - // $FlowFixMe + // $FlowFixMe[prop-missing] value.status = 'fulfilled'; // Is there some more useful representation for the chunk? - // $FlowFixMe + // $FlowFixMe[prop-missing] value.value = href; // Create a fake stack frame that points to the beginning of the chunk. This is // probably not source mapped so will link to the compiled source rather than diff --git a/packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerBrowser.js b/packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerBrowser.js index 0100789347b0..1a051eabd7bc 100644 --- a/packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerBrowser.js +++ b/packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerBrowser.js @@ -153,6 +153,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); debugStream.pipeTo(debugChannelWritable); @@ -175,6 +176,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); return stream; @@ -204,6 +206,7 @@ function prerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); resolve({prelude: stream}); diff --git a/packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerEdge.js b/packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerEdge.js index 18e71fdeab6c..0e3c3d51c5cc 100644 --- a/packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerEdge.js +++ b/packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerEdge.js @@ -158,6 +158,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); debugStream.pipeTo(debugChannelWritable); @@ -180,6 +181,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); return stream; @@ -209,6 +211,7 @@ function prerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); resolve({prelude: stream}); @@ -309,7 +312,7 @@ 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[prop-missing] should be able to pass mixed iterator.throw(reason).then(error, error); } } diff --git a/packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerNode.js b/packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerNode.js index 6c8d759a99ac..9e2873370cab 100644 --- a/packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerNode.js +++ b/packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerNode.js @@ -130,11 +130,11 @@ function startReadingFromDebugChannelReadable( const ws: WebSocket = (stream: any); ws.binaryType = 'arraybuffer'; ws.addEventListener('message', event => { - // $FlowFixMe + // $FlowFixMe[incompatible-type] onData(event.data); }); ws.addEventListener('error', event => { - // $FlowFixMe + // $FlowFixMe[prop-missing] onError(event.error); }); ws.addEventListener('close', onClose); @@ -381,6 +381,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); debugStream.pipeTo(debugChannelWritable); @@ -405,6 +406,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); return stream; @@ -517,6 +519,7 @@ function prerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); resolve({prelude: stream}); @@ -690,7 +693,7 @@ function decodeReplyFromBusboy( busboyStream.on('error', err => { reportGlobalError( response, - // $FlowFixMe[incompatible-call] types Error and mixed are incompatible + // $FlowFixMe[incompatible-type] types Error and mixed are incompatible err, ); }); @@ -762,7 +765,7 @@ 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[prop-missing] should be able to pass mixed iterator.throw(reason).then(error, error); } } diff --git a/packages/react-server-dom-unbundled/src/ReactFlightUnbundledNodeLoader.js b/packages/react-server-dom-unbundled/src/ReactFlightUnbundledNodeLoader.js index 9799acc3a07b..aa0448b2735c 100644 --- a/packages/react-server-dom-unbundled/src/ReactFlightUnbundledNodeLoader.js +++ b/packages/react-server-dom-unbundled/src/ReactFlightUnbundledNodeLoader.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,7 @@ async function transformModuleIfNeeded( const sourceMapString = typeof sourceMapResult.source === 'string' ? sourceMapResult.source - : // $FlowFixMe + : // $FlowFixMe[extra-arg] sourceMapResult.source.toString('utf8'); sourceMap = JSON.parse(sourceMapString); diff --git a/packages/react-server-dom-unbundled/src/ReactFlightUnbundledReferences.js b/packages/react-server-dom-unbundled/src/ReactFlightUnbundledReferences.js index b9f90b4d14b8..c12614331dca 100644 --- a/packages/react-server-dom-unbundled/src/ReactFlightUnbundledReferences.js +++ b/packages/react-server-dom-unbundled/src/ReactFlightUnbundledReferences.js @@ -63,7 +63,7 @@ const FunctionBind = Function.prototype.bind; // $FlowFixMe[method-unbinding] 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__) { @@ -261,6 +261,8 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe { const clientReference: ClientReference = registerClientReferenceImpl(({}: any), target.$$id, true); + // $FlowFixMe[incompatible-variance] + // $FlowFixMe[incompatible-type] const proxy = new Proxy(clientReference, proxyHandlers); // Treat this as a resolved Promise for React's use() @@ -355,5 +357,8 @@ export function createClientModuleProxy( moduleId, false, ); + // $FlowFixMe[incompatible-variance] + // $FlowFixMe[incompatible-type] + // $FlowFixMe[incompatible-exact] return new Proxy(clientReference, proxyHandlers); } diff --git a/packages/react-server-dom-unbundled/src/server/ReactFlightDOMServerNode.js b/packages/react-server-dom-unbundled/src/server/ReactFlightDOMServerNode.js index eac2f9c48317..175ca0a86ef2 100644 --- a/packages/react-server-dom-unbundled/src/server/ReactFlightDOMServerNode.js +++ b/packages/react-server-dom-unbundled/src/server/ReactFlightDOMServerNode.js @@ -130,11 +130,11 @@ function startReadingFromDebugChannelReadable( const ws: WebSocket = (stream: any); ws.binaryType = 'arraybuffer'; ws.addEventListener('message', event => { - // $FlowFixMe + // $FlowFixMe[incompatible-type] onData(event.data); }); ws.addEventListener('error', event => { - // $FlowFixMe + // $FlowFixMe[prop-missing] onError(event.error); }); ws.addEventListener('close', onClose); @@ -381,6 +381,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); debugStream.pipeTo(debugChannelWritable); @@ -405,6 +406,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); return stream; @@ -517,6 +519,7 @@ function prerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); resolve({prelude: stream}); @@ -690,7 +693,7 @@ function decodeReplyFromBusboy( busboyStream.on('error', err => { reportGlobalError( response, - // $FlowFixMe[incompatible-call] types Error and mixed are incompatible + // $FlowFixMe[incompatible-type] types Error and mixed are incompatible err, ); }); @@ -762,7 +765,7 @@ 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[prop-missing] should be able to pass mixed iterator.throw(reason).then(error, error); } } diff --git a/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js b/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js index 9799acc3a07b..aa0448b2735c 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,7 @@ async function transformModuleIfNeeded( const sourceMapString = typeof sourceMapResult.source === 'string' ? sourceMapResult.source - : // $FlowFixMe + : // $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 b9f90b4d14b8..c12614331dca 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightWebpackReferences.js +++ b/packages/react-server-dom-webpack/src/ReactFlightWebpackReferences.js @@ -63,7 +63,7 @@ const FunctionBind = Function.prototype.bind; // $FlowFixMe[method-unbinding] 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__) { @@ -261,6 +261,8 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe { const clientReference: ClientReference = registerClientReferenceImpl(({}: any), target.$$id, true); + // $FlowFixMe[incompatible-variance] + // $FlowFixMe[incompatible-type] const proxy = new Proxy(clientReference, proxyHandlers); // Treat this as a resolved Promise for React's use() @@ -355,5 +357,8 @@ export function createClientModuleProxy( moduleId, false, ); + // $FlowFixMe[incompatible-variance] + // $FlowFixMe[incompatible-type] + // $FlowFixMe[incompatible-exact] return new Proxy(clientReference, proxyHandlers); } diff --git a/packages/react-server-dom-webpack/src/client/ReactFlightClientConfigBundlerWebpackBrowser.js b/packages/react-server-dom-webpack/src/client/ReactFlightClientConfigBundlerWebpackBrowser.js index 7f49e9fd15a8..ed26b38154b8 100644 --- a/packages/react-server-dom-webpack/src/client/ReactFlightClientConfigBundlerWebpackBrowser.js +++ b/packages/react-server-dom-webpack/src/client/ReactFlightClientConfigBundlerWebpackBrowser.js @@ -51,7 +51,7 @@ export function addChunkDebugInfo( const scriptFilename = __webpack_get_script_filename__(chunkId); let href; try { - // $FlowFixMe + // $FlowFixMe[incompatible-type] href = new URL(scriptFilename, document.baseURI).href; } catch (_) { href = scriptFilename; @@ -74,9 +74,9 @@ export function addChunkDebugInfo( } } const value = Promise.resolve(href); - // $FlowFixMe + // $FlowFixMe[prop-missing] value.status = 'fulfilled'; - // $FlowFixMe + // $FlowFixMe[prop-missing] value.value = { chunkId: chunkId, href: href, diff --git a/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerBrowser.js b/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerBrowser.js index d1d0772186e6..227671b86808 100644 --- a/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerBrowser.js +++ b/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerBrowser.js @@ -153,6 +153,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); debugStream.pipeTo(debugChannelWritable); @@ -175,6 +176,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); return stream; @@ -204,6 +206,7 @@ function prerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); resolve({prelude: stream}); diff --git a/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerEdge.js b/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerEdge.js index 1347b07dd4df..d52c32b5b1db 100644 --- a/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerEdge.js +++ b/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerEdge.js @@ -158,6 +158,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); debugStream.pipeTo(debugChannelWritable); @@ -180,6 +181,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); return stream; @@ -209,6 +211,7 @@ function prerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); resolve({prelude: stream}); @@ -309,7 +312,7 @@ 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[prop-missing] should be able to pass mixed iterator.throw(reason).then(error, error); } } diff --git a/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerNode.js b/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerNode.js index c8809b040460..6294f7d30923 100644 --- a/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerNode.js +++ b/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerNode.js @@ -130,11 +130,11 @@ function startReadingFromDebugChannelReadable( const ws: WebSocket = (stream: any); ws.binaryType = 'arraybuffer'; ws.addEventListener('message', event => { - // $FlowFixMe + // $FlowFixMe[incompatible-type] onData(event.data); }); ws.addEventListener('error', event => { - // $FlowFixMe + // $FlowFixMe[prop-missing] onError(event.error); }); ws.addEventListener('close', onClose); @@ -381,6 +381,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); debugStream.pipeTo(debugChannelWritable); @@ -405,6 +406,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); return stream; @@ -517,6 +519,7 @@ function prerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); resolve({prelude: stream}); @@ -691,6 +694,7 @@ function decodeReplyFromBusboy( reportGlobalError( response, // $FlowFixMe[incompatible-call] types Error and mixed are incompatible + // $FlowFixMe[incompatible-type] err, ); }); @@ -762,7 +766,7 @@ 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[prop-missing] should be able to pass mixed iterator.throw(reason).then(error, error); } } diff --git a/packages/react-server/src/ReactFizzComponentStack.js b/packages/react-server/src/ReactFizzComponentStack.js index 467cf48646c9..9b55480a0388 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 24e676fc7108..9f166f7e35a8 100644 --- a/packages/react-server/src/ReactFizzHooks.js +++ b/packages/react-server/src/ReactFizzHooks.js @@ -360,6 +360,7 @@ export function useReducer( init?: I => S, ): [S, Dispatch] { if (__DEV__) { + // $FlowFixMe[invalid-compare] if (reducer !== basicStateReducer) { currentHookNameInDev = 'useReducer'; } @@ -409,6 +410,7 @@ export function useReducer( isInHookUserCodeInDev = true; } let initialState; + // $FlowFixMe[invalid-compare] if (reducer === basicStateReducer) { // Special case for `useState`. initialState = @@ -445,6 +447,7 @@ function useMemo(nextCreate: () => T, deps: Array | void | null): T { const nextDeps = deps === undefined ? null : deps; + // $FlowFixMe[invalid-compare] if (workInProgressHook !== null) { const prevState = workInProgressHook.memoizedState; if (prevState !== null) { @@ -545,7 +548,7 @@ function throwOnUseEffectEventCall() { export function useEffectEvent) => Return>( callback: F, ): F { - // $FlowIgnore[incompatible-return] + // $FlowFixMe[incompatible-type] return throwOnUseEffectEventCall; } @@ -629,7 +632,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 @@ -651,7 +654,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,7 +690,7 @@ function useActionState( // $FlowIgnore[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); @@ -746,6 +749,7 @@ function useId(): string { } function use(usable: Usable): T { + // $FlowFixMe[invalid-compare] if (usable !== null && typeof usable === 'object') { // $FlowFixMe[method-unbinding] if (typeof usable.then === 'function') { @@ -803,6 +807,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 0a9fe3df4c35..a481272916b1 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): void { + // $FlowFixMe[constant-condition] if (isPrimaryRenderer) { prev.context._currentValue = prev.parentValue; } else { @@ -47,6 +48,7 @@ function popNode(prev: ContextNode): void { } function pushNode(next: ContextNode): void { + // $FlowFixMe[constant-condition] if (isPrimaryRenderer) { next.context._currentValue = next.value; } else { @@ -162,7 +164,7 @@ export function switchContext(newSnapshot: ContextSnapshot): void { const next = newSnapshot; 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]: This has to be non-null since it's not equal to prev. pushAllNext(next); } else if (next === null) { popAllPrevious(prev); @@ -182,6 +184,7 @@ export function pushProvider( nextValue: T, ): ContextSnapshot { let prevValue; + // $FlowFixMe[constant-condition] if (isPrimaryRenderer) { prevValue = context._currentValue; context._currentValue = nextValue; @@ -243,6 +246,7 @@ export function popProvider(context: ReactContext): ContextSnapshot { ); } } + // $FlowFixMe[constant-condition] if (isPrimaryRenderer) { const value = prevSnapshot.parentValue; prevSnapshot.context._currentValue = value; @@ -284,6 +288,7 @@ export function getActiveContext(): ContextSnapshot { } export function readContext(context: ReactContext): 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 522e6e887a79..fcb4962f62c8 100644 --- a/packages/react-server/src/ReactFizzServer.js +++ b/packages/react-server/src/ReactFizzServer.js @@ -536,6 +536,7 @@ function RequestInstance( progressiveChunkSize === undefined ? DEFAULT_PROGRESSIVE_CHUNK_SIZE : progressiveChunkSize; + // $FlowFixMe[constant-condition] this.status = isWorkLoopExternallyDriven ? OPEN : OPENING; this.fatalError = null; this.aborted = false; @@ -791,6 +792,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; @@ -801,6 +803,7 @@ export function resolveRequest(): null | Request { function pingTask(request: Request, task: Task): void { const pingedTasks = request.pingedTasks; pingedTasks.push(task); + // $FlowFixMe[constant-condition] if (isWorkLoopExternallyDriven) { return; } else { @@ -1410,7 +1413,7 @@ function renderSuspenseBoundary( } return; } - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. const task: RenderTask = someTask; const prevKeyPath = task.keyPath; @@ -2220,11 +2223,12 @@ 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 // thenable state. - // $FlowFixMe + // $FlowFixMe[underconstrained-implicit-instantiation] let step = readPreviousThenableFromState(); while (step !== undefined) { if (step.done) { @@ -2360,7 +2364,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 @@ -2985,9 +2989,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] -- falls through case REACT_STRICT_MODE_TYPE: + // $FlowFixMe[invalid-compare] -- falls through case REACT_PROFILER_TYPE: + // $FlowFixMe[invalid-compare] -- falls through case REACT_FRAGMENT_TYPE: { const prevKeyPath = task.keyPath; task.keyPath = keyPath; @@ -2995,14 +3003,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); @@ -3010,6 +3021,7 @@ function renderElement( } // Fallthrough } + // $FlowFixMe[invalid-compare] case REACT_SCOPE_TYPE: { if (enableScopeAPI) { const prevKeyPath = task.keyPath; @@ -3020,33 +3032,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 = (type: ReactConsumerType) ._context; renderContextConsumer(request, task, keyPath, context, props); return; } + // $FlowFixMe[invalid-compare] case REACT_LAZY_TYPE: { renderLazyComponent(request, task, keyPath, type, props, ref); return; @@ -3059,6 +3078,7 @@ function renderElement( if ( type === undefined || (typeof type === 'object' && + // $FlowFixMe[invalid-compare] type !== null && Object.keys(type).length === 0) ) { @@ -3544,11 +3564,12 @@ 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 // thenable state. - // $FlowFixMe + // $FlowFixMe[underconstrained-implicit-instantiation] let step = readPreviousThenableFromState(); while (step !== undefined) { if (step.done) { @@ -3838,7 +3859,7 @@ function renderChildrenArray( if (task.replay !== null) { replayFragment( request, - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. task, children, childIndex, @@ -3978,6 +3999,7 @@ function trackPostpone( return; } + // $FlowFixMe[invalid-compare] if (boundary !== null && boundary.status === PENDING) { const boundaryNode = trackPostponedBoundary( request, @@ -4009,6 +4031,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. @@ -4221,6 +4244,7 @@ function renderNode( if (request.aborted) { // 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') { @@ -4231,7 +4255,7 @@ function renderNode( : null; const newTask = spawnNewSuspendedReplayTask( request, - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. task, thenableState, ); @@ -4267,7 +4291,7 @@ function renderNode( : null; const newTask = spawnNewSuspendedReplayTask( request, - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. task, thenableState, ); @@ -4322,6 +4346,7 @@ function renderNode( if (request.aborted) { // 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') { @@ -4332,7 +4357,7 @@ function renderNode( : null; const newTask = spawnNewSuspendedRenderTask( request, - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. task, thenableState, ); @@ -4367,7 +4392,7 @@ function renderNode( : null; const newTask = spawnNewSuspendedRenderTask( request, - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. task, thenableState, ); @@ -4663,7 +4688,9 @@ function abortTask(task: Task, request: Request): 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) ) { @@ -4980,6 +5007,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; @@ -5149,13 +5177,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, ); @@ -5343,6 +5371,7 @@ function retryReplayTask(request: Request, task: ReplayTask): void { return; } + // $FlowFixMe[invalid-compare] if (typeof x === 'object' && x !== null) { // $FlowFixMe[method-unbinding] if (typeof x.then === 'function') { @@ -6148,11 +6177,13 @@ function flushCompletedQueues( } export function startWork(request: Request): void { + // $FlowFixMe[constant-condition] if (isWorkLoopExternallyDriven) { return; } else { request.flushScheduled = request.destination !== null; // When prerendering we use microtasks for pinging work + // $FlowFixMe[constant-condition] if (supportsRequestStorage) { scheduleMicrotask(() => requestStorage.run(request, performWork, request), @@ -6175,6 +6206,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/ReactFizzThenable.js b/packages/react-server/src/ReactFizzThenable.js index ea6fbec7a5db..cf6ddb384361 100644 --- a/packages/react-server/src/ReactFizzThenable.js +++ b/packages/react-server/src/ReactFizzThenable.js @@ -277,7 +277,7 @@ export function ensureSuspendableThenableStateDEV( switch (lastThenable.status) { case 'fulfilled': { const previousThenableValue = lastThenable.value; - // $FlowIgnore[method-unbinding] We rebind .then immediately. + // $FlowFixMe[method-unbinding] We rebind .then immediately. const previousThenableThen = lastThenable.then.bind(lastThenable); delete lastThenable.value; delete (lastThenable: any).status; @@ -295,7 +295,7 @@ export function ensureSuspendableThenableStateDEV( } case 'rejected': { const previousThenableReason = lastThenable.reason; - // $FlowIgnore[method-unbinding] We rebind .then immediately. + // $FlowFixMe[method-unbinding] We rebind .then immediately. const previousThenableThen = lastThenable.then.bind(lastThenable); delete lastThenable.reason; delete (lastThenable: any).status; diff --git a/packages/react-server/src/ReactFizzViewTransitionComponent.js b/packages/react-server/src/ReactFizzViewTransitionComponent.js index d2e6c0e120f3..739e4318ee4b 100644 --- a/packages/react-server/src/ReactFizzViewTransitionComponent.js +++ b/packages/react-server/src/ReactFizzViewTransitionComponent.js @@ -36,6 +36,7 @@ function getClassNameByType(classByType: ?ViewTransitionClass): ?string { 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/ReactFlightActionServer.js b/packages/react-server/src/ReactFlightActionServer.js index a3a47a9f9793..c0cd8a005eba 100644 --- a/packages/react-server/src/ReactFlightActionServer.js +++ b/packages/react-server/src/ReactFlightActionServer.js @@ -95,10 +95,10 @@ function decodeBoundActionMetaData( bound: null | Promise>, }>(actionResponse); // Force it to initialize - // $FlowFixMe + // $FlowFixMe[incompatible-type] refPromise.then(() => {}); if (refPromise.status !== 'fulfilled') { - // $FlowFixMe + // $FlowFixMe[prop-missing] throw refPromise.reason; } return refPromise.value; @@ -118,7 +118,7 @@ export function decodeAction( // $FlowFixMe[prop-missing] 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/ReactFlightHooks.js b/packages/react-server/src/ReactFlightHooks.js index d814de462982..19851d6c0993 100644 --- a/packages/react-server/src/ReactFlightHooks.js +++ b/packages/react-server/src/ReactFlightHooks.js @@ -128,6 +128,7 @@ function useId(): string { function use(usable: Usable): T { if ( + // $FlowFixMe[invalid-compare] (usable !== null && typeof usable === 'object') || typeof usable === 'function' ) { diff --git a/packages/react-server/src/ReactFlightReplyServer.js b/packages/react-server/src/ReactFlightReplyServer.js index 7248dc537678..c24b0d2f8567 100644 --- a/packages/react-server/src/ReactFlightReplyServer.js +++ b/packages/react-server/src/ReactFlightReplyServer.js @@ -151,6 +151,7 @@ ReactPromise.prototype.then = function ( while (inspectedValue instanceof ReactPromise) { cycleProtection++; if ( + // $FlowFixMe[invalid-compare] inspectedValue === chunk || visited.has(inspectedValue) || cycleProtection > 1000 @@ -161,6 +162,7 @@ ReactPromise.prototype.then = function ( return; } visited.add(inspectedValue); + // $FlowFixMe[invalid-compare] if (inspectedValue.status === INITIALIZED) { inspectedValue = inspectedValue.value; } else { @@ -301,7 +303,7 @@ function triggerErrorOnChunk( // a stream chunk since any other row shouldn't have more than one entry. const streamChunk: InitializedStreamChunk = (chunk: any); const controller = streamChunk.reason; - // $FlowFixMe[incompatible-call]: The error method should accept mixed. + // $FlowFixMe[incompatible-type]: The error method should accept mixed. controller.error(error); return; } @@ -1041,7 +1043,7 @@ function getOutlinedModel( switch (chunk.status) { case RESOLVED_MODEL: initializeModelChunk(chunk); - // $FlowFixMe[incompatible-cast] We just initialized this chunk so it can't be a ResolvedModelChunk anymore. + // $FlowFixMe[incompatible-type] We just initialized this chunk so it can't be a ResolvedModelChunk anymore. chunk = (chunk: Exclude, ResolvedModelChunk>); break; } @@ -1067,6 +1069,7 @@ function getOutlinedModel( const name = path[i]; if ( typeof value === 'object' && + // $FlowFixMe[invalid-compare] This check is still needed at runtime. value !== null && (getPrototypeOf(value) === ObjectPrototype || getPrototypeOf(value) === ArrayPrototype) && @@ -1077,7 +1080,7 @@ function getOutlinedModel( localLength = 0; arrayRoot = rootArrayContexts.get( - // $FlowFixMe[incompatible-cast] Our `isArray` typing can't narrow `mixed` + // $FlowFixMe[incompatible-type] Our `isArray` typing can't narrow `mixed` (value: $ReadOnlyArray), ) || arrayRoot; } else { @@ -1434,7 +1437,7 @@ function parseReadableStream( } closed = true; if (previousBlockedChunk === null) { - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] controller.error(error); } else { const blockedChunk = previousBlockedChunk; @@ -1664,7 +1667,7 @@ function parseModelString( ); const referencedFormDataKey = formDataKey.slice(formPrefix.length); for (let i = 0; i < referencedFormDataValue.length; i++) { - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] data.append(referencedFormDataKey, referencedFormDataValue[i]); } consumeBackingEntry(backingFormData, formDataKey); diff --git a/packages/react-server/src/ReactFlightServer.js b/packages/react-server/src/ReactFlightServer.js index ef6e9caac4b2..a45efebaa8f5 100644 --- a/packages/react-server/src/ReactFlightServer.js +++ b/packages/react-server/src/ReactFlightServer.js @@ -393,7 +393,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]: We should be able to get descriptors from any function. originalMethod, 'name', ); @@ -422,6 +422,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) { @@ -438,6 +439,7 @@ function patchConsole(consoleInst: typeof console, methodName: string) { } } +// $FlowFixMe[invalid-compare] if (__DEV__ && typeof console === 'object' && console !== null) { // Instrument console to capture logs for replaying on the client. patchConsole(console, 'assert'); @@ -870,6 +872,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; @@ -1170,7 +1173,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 { @@ -1248,7 +1251,8 @@ function serializeReadableStream( erroredTask(request, streamTask, reason); enqueueFlush(request); - // $FlowFixMe should be able to pass mixed + // $FlowFixMe[incompatible-type] should be able to pass mixed + // $FlowFixMe[incompatible-use] reader.cancel(reason).then(error, error); } function abortStream() { @@ -1267,7 +1271,7 @@ function serializeReadableStream( erroredTask(request, streamTask, reason); enqueueFlush(request); } - // $FlowFixMe should be able to pass mixed + // $FlowFixMe[incompatible-use] should be able to pass mixed reader.cancel(reason).then(error, error); } @@ -1381,7 +1385,7 @@ 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[prop-missing] should be able to pass mixed iterator.throw(reason).then(error, error); } } @@ -1403,7 +1407,7 @@ 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[prop-missing] should be able to pass mixed iterator.throw(reason).then(error, error); } } @@ -1603,10 +1607,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) { @@ -1643,10 +1647,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) { @@ -1746,6 +1750,7 @@ function renderFunctionComponent( } } prepareToUseHooksForComponent(prevThenableState, componentDebugInfo); + // $FlowFixMe[constant-condition] if (supportsComponentStorage) { // Run the component in an Async Context that tracks the current owner. if (task.debugTask) { @@ -1789,6 +1794,7 @@ function renderFunctionComponent( if (request.status === ABORTING) { if ( typeof result === 'object' && + // $FlowFixMe[invalid-compare] result !== null && typeof result.then === 'function' && !isClientReference(result) @@ -1894,6 +1900,7 @@ function warnForMissingKey( ); }; + // $FlowFixMe[constant-condition] if (supportsComponentStorage) { // Run the component in an Async Context that tracks the current owner. if (debugTask) { @@ -3074,6 +3081,7 @@ function serializeServerReference( request.bundlerConfig, serverReference, ); + // $FlowFixMe[constant-condition] if (error) { const frames = parseStackTrace(error, 1); if (frames.length > 0) { @@ -3267,17 +3275,17 @@ 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) { const digest = ''; emitErrorChunk(request, id, digest, reason, true, null); enqueueFlush(request); - // $FlowFixMe should be able to pass mixed + // $FlowFixMe[incompatible-type] should be able to pass mixed reader.cancel(reason).then(noop, noop); } - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] reader.read().then(progress).catch(error); return '$B' + id.toString(16); } @@ -3315,7 +3323,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) { @@ -3325,7 +3333,8 @@ 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 + // $FlowFixMe[incompatible-type] should be able to pass mixed + // $FlowFixMe[incompatible-use] reader.cancel(reason).then(error, error); } function abortBlob() { @@ -3344,13 +3353,13 @@ function serializeBlob(request: Request, blob: Blob): string { erroredTask(request, newTask, reason); enqueueFlush(request); } - // $FlowFixMe should be able to pass mixed + // $FlowFixMe[incompatible-use] should be able to pass mixed reader.cancel(reason).then(error, error); } request.cacheController.signal.addEventListener('abort', abortBlob); - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] reader.read().then(progress).catch(error); return '$B' + newTask.id.toString(16); @@ -3418,6 +3427,7 @@ function renderModel( getSuspendedThenable() : thrownValue; + // $FlowFixMe[invalid-compare] if (typeof x === 'object' && x !== null) { // $FlowFixMe[method-unbinding] if (typeof x.then === 'function') { @@ -3945,7 +3955,7 @@ function renderModelDestructive( } } - // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] return value; } @@ -3966,6 +3976,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 @@ -4110,6 +4121,7 @@ function logRecoverableError( try { const onError = request.onError; if (__DEV__ && task !== null) { + // $FlowFixMe[constant-condition] if (supportsRequestStorage) { errorDigest = requestStorage.run( undefined, @@ -4122,6 +4134,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); @@ -4740,6 +4753,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( @@ -5155,7 +5169,7 @@ function renderDebugModel( return instanceDescription; } - // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] return value; } @@ -5307,6 +5321,7 @@ 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 @@ -5370,10 +5385,10 @@ function emitOutlinedDebugModelChunk( } let json: string; try { - // $FlowFixMe[incompatible-cast] stringify can return null + // $FlowFixMe[incompatible-type] stringify can return null json = (stringify(model, replacer): string); } catch (x) { - // $FlowFixMe[incompatible-cast] stringify can return null + // $FlowFixMe[incompatible-type] stringify can return null json = (stringify( 'Unknown Value: React could not send it from the server.\n' + x.message, ): string); @@ -5724,6 +5739,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); @@ -5942,6 +5958,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') { @@ -6282,6 +6299,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-server/src/ReactFlightServerConfigDebugNode.js b/packages/react-server/src/ReactFlightServerConfigDebugNode.js index 9bb521be4065..afd397b041e0 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 be8bf9534670..19e03a14756e 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 d93e5f1a0ddf..0208af4c975b 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 7987b9b262fa..bee6d7ad3975 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/ReactServerStreamConfigBrowser.js b/packages/react-server/src/ReactServerStreamConfigBrowser.js index 41d9aedd0053..fedb8d47fcfe 100644 --- a/packages/react-server/src/ReactServerStreamConfigBrowser.js +++ b/packages/react-server/src/ReactServerStreamConfigBrowser.js @@ -178,7 +178,7 @@ export function byteLengthOfBinaryChunk(chunk: BinaryChunk): number { 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]: This is an Error object or the destination accepts other types. destination.error(error); } else { // Earlier implementations doesn't support this method. In that environment you're @@ -196,7 +196,7 @@ export {createFastHashJS as createFastHash} from 'react-server/src/createFastHas 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]: We always expect a string result with readAsDataURL. 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 a9079bee43a6..ce52a5b521e8 100644 --- a/packages/react-server/src/ReactServerStreamConfigBun.js +++ b/packages/react-server/src/ReactServerStreamConfigBun.js @@ -55,7 +55,7 @@ export function writeChunk( return; } - // $FlowFixMe[incompatible-call]: write() is compatible with both types in Bun + // $FlowFixMe[incompatible-type]: write() is compatible with both types in Bun destination.write(chunk); } @@ -63,7 +63,7 @@ export function writeChunkAndReturn( destination: Destination, chunk: PrecomputedChunk | Chunk | BinaryChunk, ): boolean { - // $FlowFixMe[incompatible-call]: write() is compatible with both types in Bun + // $FlowFixMe[incompatible-type]: write() is compatible with both types in Bun return !!destination.write(chunk); } @@ -100,13 +100,13 @@ export function closeWithError(destination: Destination, error: mixed): void { // $FlowFixMe[incompatible-use] // $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]: This is an Error object or the destination accepts other types. 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]: This is an Error object or the destination accepts other types. destination.destroy(error); // $FlowFixMe[incompatible-use] diff --git a/packages/react-server/src/ReactServerStreamConfigEdge.js b/packages/react-server/src/ReactServerStreamConfigEdge.js index 90affdc6b8ac..588f513d3c27 100644 --- a/packages/react-server/src/ReactServerStreamConfigEdge.js +++ b/packages/react-server/src/ReactServerStreamConfigEdge.js @@ -165,7 +165,7 @@ export function byteLengthOfBinaryChunk(chunk: BinaryChunk): number { 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]: This is an Error object or the destination accepts other types. 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 90609da2c45d..dc6364b62499 100644 --- a/packages/react-server/src/ReactServerStreamConfigNode.js +++ b/packages/react-server/src/ReactServerStreamConfigNode.js @@ -231,7 +231,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]: This is an Error object or the destination accepts other types. destination.destroy(error); } diff --git a/packages/react-server/src/ReactSharedInternalsServer.js b/packages/react-server/src/ReactSharedInternalsServer.js index efc3588a6452..0c2bb73a2b61 100644 --- a/packages/react-server/src/ReactSharedInternalsServer.js +++ b/packages/react-server/src/ReactSharedInternalsServer.js @@ -12,7 +12,8 @@ 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[incompatible-type]: It's defined in the one we resolve to. + // $FlowFixMe[missing-export] React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; if (!ReactSharedInternalsServer) { diff --git a/packages/react-server/src/flight/ReactFlightCurrentOwner.js b/packages/react-server/src/flight/ReactFlightCurrentOwner.js index fec9e86829ba..e2eb66c19d73 100644 --- a/packages/react-server/src/flight/ReactFlightCurrentOwner.js +++ b/packages/react-server/src/flight/ReactFlightCurrentOwner.js @@ -22,6 +22,7 @@ export function setCurrentOwner(componentInfo: null | ReactComponentInfo) { export function resolveOwner(): null | ReactComponentInfo { if (currentOwner) return currentOwner; + // $FlowFixMe[constant-condition] if (supportsComponentStorage) { const owner = componentStorage.getStore(); if (owner) return owner; diff --git a/packages/react-test-renderer/src/ReactTestRenderer.js b/packages/react-test-renderer/src/ReactTestRenderer.js index 08676503fa49..538290007fc0 100644 --- a/packages/react-test-renderer/src/ReactTestRenderer.js +++ b/packages/react-test-renderer/src/ReactTestRenderer.js @@ -67,6 +67,7 @@ import type {WorkTag} from 'react-reconciler/src/ReactWorkTags'; const defaultOnDefaultTransitionIndicator: () => void | (() => void) = noop; // $FlowFixMe[prop-missing]: This is only in the development export. +// $FlowFixMe[missing-export] const act = React.act; // TODO: Remove from public bundle @@ -179,7 +180,7 @@ function flatten(arr) { // $FlowFixMe[incompatible-use] n.i += 1; if (isArray(el)) { - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] stack.push(n); stack.push({i: 0, array: el}); break; @@ -494,6 +495,7 @@ function create( global.IS_REACT_NATIVE_TEST_ENVIRONMENT !== true; let isConcurrent = isConcurrentOnly; let isStrictMode = false; + // $FlowFixMe[invalid-compare] if (typeof options === 'object' && options !== null) { if (typeof options.createNodeMock === 'function') { // $FlowFixMe[incompatible-type] found when upgrading Flow @@ -529,6 +531,7 @@ function create( throw new Error('something went wrong'); } + // $FlowFixMe[incompatible-type] updateContainer(element, root, null, null); const entry = { @@ -580,6 +583,7 @@ function create( if (root == null || root.current == null) { return; } + // $FlowFixMe[incompatible-type] updateContainer(newElement, root, null, null); }, unmount() { diff --git a/packages/react/index.development.js b/packages/react/index.development.js index ed4a5a325d95..5ee39427fdde 100644 --- a/packages/react/index.development.js +++ b/packages/react/index.development.js @@ -12,11 +12,13 @@ export type ElementType = React$ElementType; export type Element<+C> = React$Element; export type Key = React$Key; export type Node = React$Node; -export type Context = React$Context; +// eslint-disable-next-line no-undef +export type Context = React.Context; export type Portal = React$Portal; -export type ElementProps = React$ElementProps; +export type ElementProps = React$ElementConfig; export type ElementConfig = React$ElementConfig; -export type ElementRef = React$ElementRef; +// eslint-disable-next-line no-undef +export type ElementRef = React.ElementRef; export type ChildrenArray<+T> = $ReadOnlyArray> | T; // Export all exports so that they're available in tests. diff --git a/packages/react/index.js b/packages/react/index.js index 78b11b809e75..140174ec01de 100644 --- a/packages/react/index.js +++ b/packages/react/index.js @@ -13,12 +13,15 @@ export type Element<+C> = React$Element; export type MixedElement = React$Element; export type Key = React$Key; export type Node = React$Node; -export type Context = React$Context; +// eslint-disable-next-line no-undef +export type Context = React.Context; export type Portal = React$Portal; -export type RefSetter<-I> = React$RefSetter; -export type ElementProps = React$ElementProps; +// eslint-disable-next-line no-undef +export type RefSetter<-I> = React.RefSetter; +export type ElementProps = React$ElementConfig; export type ElementConfig = React$ElementConfig; -export type ElementRef = React$ElementRef; +// eslint-disable-next-line no-undef +export type ElementRef = React.ElementRef; export type ChildrenArray<+T> = $ReadOnlyArray> | T; export { diff --git a/packages/react/src/ReactAct.js b/packages/react/src/ReactAct.js index 1e74d222a29a..e58631e43b7c 100644 --- a/packages/react/src/ReactAct.js +++ b/packages/react/src/ReactAct.js @@ -102,6 +102,7 @@ export function act(callback: () => T | Thenable): Thenable { } if ( + // $FlowFixMe[invalid-compare] result !== null && typeof result === 'object' && // $FlowFixMe[method-unbinding] diff --git a/packages/react/src/ReactCacheClient.js b/packages/react/src/ReactCacheClient.js index ef1e8d6d1da5..69bfdfc7559f 100644 --- a/packages/react/src/ReactCacheClient.js +++ b/packages/react/src/ReactCacheClient.js @@ -27,7 +27,7 @@ function noopCache, T>(fn: (...A) => T): (...A) => T { // preserved, the length of the new function is 0, etc. That way apps can'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]: We don't want to use rest arguments since we transpile the code. return fn.apply(null, arguments); }; } diff --git a/packages/react/src/ReactCacheImpl.js b/packages/react/src/ReactCacheImpl.js index 2ff7431fc519..296c6f392deb 100644 --- a/packages/react/src/ReactCacheImpl.js +++ b/packages/react/src/ReactCacheImpl.js @@ -57,7 +57,7 @@ export function cache, T>(fn: (...A) => T): (...A) => T { const dispatcher = ReactSharedInternals.A; 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]: We don't want to use rest arguments since we transpile the code. return fn.apply(null, arguments); } const fnMap: WeakMap> = dispatcher.getCacheForType( @@ -75,6 +75,7 @@ export function cache, 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 @@ -111,7 +112,7 @@ export function cache, T>(fn: (...A) => T): (...A) => T { throw cacheNode.v; } try { - // $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code. + // $FlowFixMe[incompatible-type]: We don't want to use rest arguments since we transpile the code. const result = fn.apply(null, arguments); const terminatedNode: TerminatedCacheNode = (cacheNode: any); terminatedNode.s = TERMINATED; diff --git a/packages/react/src/ReactChildren.js b/packages/react/src/ReactChildren.js index d4c41d6669a3..3969d410d656 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 b380750ca10a..ff6f9b772738 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; } } @@ -145,12 +147,14 @@ function lazyInitializer(payload: Payload): T { // $FlowFixMe[cannot-write] ioInfo.end = performance.now(); // Hide unhandled rejections. - // $FlowFixMe + // $FlowFixMe[incompatible-use] 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; } } diff --git a/packages/react/src/ReactStartTransition.js b/packages/react/src/ReactStartTransition.js index 3e353a3b6153..bb5a36828581 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' ) { @@ -140,6 +141,7 @@ export function startGestureTransition( if (enableViewTransition) { currentTransition.types = null; } + // $FlowFixMe[constant-condition] if (enableGestureTransition) { currentTransition.gesture = provider; } @@ -158,6 +160,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 99bf73ac2544..c80a18a597b2 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,6 +87,7 @@ 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') { throw new Error( @@ -127,6 +129,7 @@ export function taintObjectReference( ); } if ( + // $FlowFixMe[invalid-compare] object === null || (typeof object !== 'object' && typeof object !== 'function') ) { diff --git a/packages/scheduler/src/SchedulerMinHeap.js b/packages/scheduler/src/SchedulerMinHeap.js index da997bad3577..4601bb056084 100644 --- a/packages/scheduler/src/SchedulerMinHeap.js +++ b/packages/scheduler/src/SchedulerMinHeap.js @@ -33,7 +33,7 @@ export function pop(heap: Heap): T | null { if (last !== first) { // $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 9fdd5906af62..22d1d71748bf 100644 --- a/packages/scheduler/src/SchedulerProfiling.js +++ b/packages/scheduler/src/SchedulerProfiling.js @@ -47,7 +47,7 @@ function logEvent(entries: Array) { return; } const newEventLog = new Int32Array(eventLogSize * 4); - // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] found when upgrading Flow newEventLog.set(eventLog); eventLogBuffer = newEventLog.buffer; eventLog = newEventLog; @@ -80,6 +80,7 @@ export function markTaskStart( }, ms: number, ) { + // $FlowFixMe[constant-condition] if (enableProfiling) { if (eventLog !== null) { // performance.now returns a float, representing milliseconds. When the @@ -98,6 +99,7 @@ export function markTaskCompleted( }, ms: number, ) { + // $FlowFixMe[constant-condition] if (enableProfiling) { if (eventLog !== null) { logEvent([TaskCompleteEvent, ms * 1000, task.id]); @@ -113,6 +115,7 @@ export function markTaskCanceled( }, ms: number, ) { + // $FlowFixMe[constant-condition] if (enableProfiling) { if (eventLog !== null) { logEvent([TaskCancelEvent, ms * 1000, task.id]); @@ -128,6 +131,7 @@ export function markTaskErrored( }, ms: number, ) { + // $FlowFixMe[constant-condition] if (enableProfiling) { if (eventLog !== null) { logEvent([TaskErrorEvent, ms * 1000, task.id]); @@ -143,6 +147,7 @@ export function markTaskRun( }, ms: number, ) { + // $FlowFixMe[constant-condition] if (enableProfiling) { runIdCounter++; @@ -153,6 +158,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]); @@ -161,6 +167,7 @@ export function markTaskYield(task: {id: number, ...}, ms: number) { } export function markSchedulerSuspended(ms: number) { + // $FlowFixMe[constant-condition] if (enableProfiling) { mainThreadIdCounter++; @@ -171,6 +178,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 88239b710676..eaba90d816f2 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); @@ -164,6 +167,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; @@ -178,6 +182,7 @@ function flushWork(initialTime: number) { currentTask = null; currentPriorityLevel = previousPriorityLevel; isPerformingWork = false; + // $FlowFixMe[constant-condition] if (enableProfiling) { const currentTime = getCurrentTime(); markSchedulerSuspended(currentTime); @@ -205,8 +210,9 @@ 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] found when upgrading Flow markTaskRun(currentTask, currentTime); } const continuationCallback = callback(didUserCallbackTimeout); @@ -216,15 +222,17 @@ 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] found when upgrading Flow markTaskYield(currentTask, currentTime); } advanceTimers(currentTime); return true; } else { + // $FlowFixMe[constant-condition] if (enableProfiling) { - // $FlowFixMe[incompatible-call] found when upgrading Flow + // $FlowFixMe[incompatible-type] found when upgrading Flow markTaskCompleted(currentTask, currentTime); // $FlowFixMe[incompatible-use] found when upgrading Flow currentTask.isQueued = false; @@ -309,7 +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. @@ -332,6 +340,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) { @@ -378,6 +387,7 @@ function unstable_scheduleCallback( expirationTime, sortIndex: -1, }; + // $FlowFixMe[constant-condition] if (enableProfiling) { newTask.isQueued = false; } @@ -400,6 +410,7 @@ function unstable_scheduleCallback( } else { newTask.sortIndex = expirationTime; push(taskQueue, newTask); + // $FlowFixMe[constant-condition] if (enableProfiling) { markTaskStart(newTask, currentTime); newTask.isQueued = true; @@ -416,6 +427,7 @@ function unstable_scheduleCallback( } function unstable_cancelCallback(task: Task) { + // $FlowFixMe[constant-condition] if (enableProfiling) { if (task.isQueued) { const currentTime = getCurrentTime(); @@ -460,6 +472,7 @@ function shouldYieldToHost(): boolean { } function requestPaint() { + // $FlowFixMe[constant-condition] if (enableRequestPaint) { needsPaint = true; } @@ -483,6 +496,7 @@ function forceFrameRate(fps: number) { } const performWorkUntilDeadline = () => { + // $FlowFixMe[constant-condition] if (enableRequestPaint) { needsPaint = false; } @@ -590,6 +604,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 cf76126410e6..50f0988e1e69 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); @@ -164,6 +167,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; @@ -178,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); @@ -206,8 +211,10 @@ 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] markTaskRun(currentTask, currentTime); } const continuationCallback = callback(didUserCallbackTimeout); @@ -217,8 +224,10 @@ 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] markTaskYield(currentTask, currentTime); } advanceTimers(currentTime); @@ -232,8 +241,10 @@ 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] markTaskCompleted(currentTask, currentTime); // $FlowFixMe[incompatible-use] found when upgrading Flow currentTask.isQueued = false; @@ -314,6 +325,7 @@ function unstable_wrapCallback) => mixed>(callback: T): T { var parentPriorityLevel = currentPriorityLevel; // $FlowFixMe[incompatible-return] // $FlowFixMe[missing-this-annot] + // $FlowFixMe[incompatible-type] return function () { // This is a fork of runWithPriority, inlined for performance. var previousPriorityLevel = currentPriorityLevel; @@ -335,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) { @@ -376,6 +389,7 @@ function unstable_scheduleCallback( expirationTime, sortIndex: -1, }; + // $FlowFixMe[constant-condition] if (enableProfiling) { newTask.isQueued = false; } @@ -398,6 +412,7 @@ function unstable_scheduleCallback( } else { newTask.sortIndex = expirationTime; push(taskQueue, newTask); + // $FlowFixMe[constant-condition] if (enableProfiling) { markTaskStart(newTask, currentTime); newTask.isQueued = true; @@ -414,6 +429,7 @@ function unstable_scheduleCallback( } function unstable_cancelCallback(task: Task) { + // $FlowFixMe[constant-condition] if (enableProfiling) { if (task.isQueued) { const currentTime = getCurrentTime(); @@ -569,6 +585,7 @@ function unstable_flushAllWithoutAsserting(): boolean { do { hasMoreWork = cb(true, currentMockTime); } while (hasMoreWork); + // $FlowFixMe[constant-condition] if (!hasMoreWork) { scheduledCallback = null; } @@ -672,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 700ff2e5d2c5..f79b6721c3bb 100644 --- a/packages/scheduler/src/forks/SchedulerPostTask.js +++ b/packages/scheduler/src/forks/SchedulerPostTask.js @@ -96,6 +96,7 @@ export function unstable_scheduleCallback( 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/packages/shared/CheckStringCoercion.js b/packages/shared/CheckStringCoercion.js index a186d6755d99..cfdb748d1021 100644 --- a/packages/shared/CheckStringCoercion.js +++ b/packages/shared/CheckStringCoercion.js @@ -17,7 +17,7 @@ * of the `value` object). */ -// $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible. +// $FlowFixMe[incompatible-type] only called in DEV, so void return is not possible. function typeName(value: mixed): string { if (__DEV__) { // toStringTag is needed for namespaced types like Temporal.Instant @@ -26,12 +26,12 @@ function typeName(value: mixed): string { (hasToStringTag && (value: any)[Symbol.toStringTag]) || (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] only called in DEV, so void return is not possible. function willCoercionThrow(value: mixed): boolean { if (__DEV__) { try { diff --git a/scripts/flow/environment.js b/scripts/flow/environment.js index 180ee3838dee..2e32b4cb28e5 100644 --- a/scripts/flow/environment.js +++ b/scripts/flow/environment.js @@ -85,7 +85,7 @@ declare class ScrollTimeline extends AnimationTimeline { // $FlowFixMe[libdef-override] declare opaque type React$Element< +ElementType: React$ElementType, - +P = React$ElementProps, + +P = React$ElementConfig, >: { +type: ElementType, +props: P, diff --git a/yarn.lock b/yarn.lock index ddcbd689a91b..0373039ad469 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9247,17 +9247,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.307.1: + version "0.307.1" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.307.1.tgz#6ca6ec271a67b8fc23ab6194c26f143d1ddb6a9a" + integrity sha512-0AglecFYaFu5ooF1IJmm4SBUZO7sopMU0jTr/Bburm/XxkJUtql+MDpwqKBFe1DTd2I/3kBzqOIFgwsZ8gS7tw== -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.307.1: + version "2.307.1" + resolved "https://registry.yarnpkg.com/flow-remove-types/-/flow-remove-types-2.307.1.tgz#d5a011d47aefdfdbccbd9d8ef3b84a1fd39160cd" + integrity sha512-PdOUe0ijQQYN8aKADulTCLNL7l0Rdkmodo7/aXTr97m18uUTrGDxCAhE0kYx6JiA0EG9X/QmJUbzdoUcgNGvag== dependencies: - hermes-parser "0.29.1" + hermes-parser "0.34.0" pirates "^3.0.2" vlq "^0.2.1" @@ -10139,22 +10139,15 @@ 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-estree@0.34.0: + version "0.34.0" + resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.34.0.tgz#a6e1aa55d0ef06136158991869b97166ce62d328" + integrity sha512-6qLylexjmuKa/YYhMiNn/3VejBsdzwmYUGmNpc693/pJzymmbufhkRW/2K6GqFgu0ApRWoqF0NbM6u82jFcOXA== hermes-parser@0.32.0, hermes-parser@^0.32.0: version "0.32.0" @@ -10163,6 +10156,13 @@ hermes-parser@0.32.0, hermes-parser@^0.32.0: dependencies: hermes-estree "0.32.0" +hermes-parser@0.34.0: + version "0.34.0" + resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.34.0.tgz#f6050c7b1a5e978af551be9faf19bc7d7c050a82" + integrity sha512-tcgan5UNZvu3WwmR3jDAlmwEAR2CMv8cwQVMe5j0NrLQkstf0l3ULbYPuTZWbXxbPa0PyZPiq5LYEcFVmhM9LQ== + dependencies: + hermes-estree "0.34.0" + hermes-parser@^0.25.1: version "0.25.1" resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.25.1.tgz#5be0e487b2090886c62bd8a11724cd766d5f54d1" From 900ae094d85b11c67d53dd14af50a2bda5db4495 Mon Sep 17 00:00:00 2001 From: Sam Zhou Date: Fri, 5 Jun 2026 19:17:18 -0400 Subject: [PATCH 2/2] [flow] Bump flow to v0.317.0 (#36701) ## Summary Mostly changing the casting syntax from `(x: Y)` to `x as Y`, as the old syntax was deprecated and always causing an error in Flow ## How did you test this change? `yarn flow-ci` --- package.json | 4 +- packages/react-cache/src/LRU.js | 16 +- packages/react-cache/src/ReactCacheOld.js | 10 +- .../react-client/src/ReactFlightClient.js | 204 +++++----- .../src/ReactFlightReplyClient.js | 43 +- .../src/ReactFlightTemporaryReferences.js | 2 +- .../react-debug-tools/src/ReactDebugHooks.js | 60 ++- packages/react-devtools-core/src/backend.js | 54 ++- .../react-devtools-core/src/standalone.js | 8 +- .../src/main/index.js | 30 +- packages/react-devtools-inline/src/backend.js | 2 +- .../react-devtools-inline/src/frontend.js | 4 +- .../setupNativeStyleEditor.js | 72 ++-- .../src/backend/StyleX/utils.js | 8 +- .../src/backend/agent.js | 70 ++-- .../fiber/DevToolsFiberComponentStack.js | 4 +- .../src/backend/fiber/renderer.js | 117 +++--- .../fiber/shared/DevToolsFiberInspection.js | 4 +- .../DevToolsFiberInternalReactConstants.js | 2 +- .../src/backend/legacy/renderer.js | 6 +- .../src/backend/profilingHooks.js | 8 +- .../src/backend/shared/ReactSymbols.js | 4 +- .../src/backend/utils/index.js | 4 +- .../src/backend/utils/parseStackTrace.js | 4 +- .../backend/views/Highlighter/Highlighter.js | 2 +- .../src/backend/views/Highlighter/Overlay.js | 4 +- .../src/backend/views/Highlighter/index.js | 6 +- .../src/backend/views/TraceUpdates/canvas.js | 2 +- .../src/backend/views/TraceUpdates/index.js | 2 +- .../react-devtools-shared/src/backendAPI.js | 2 +- packages/react-devtools-shared/src/bridge.js | 2 +- .../config/DevToolsFeatureFlags.core-fb.js | 2 +- .../config/DevToolsFeatureFlags.core-oss.js | 2 +- .../DevToolsFeatureFlags.extension-fb.js | 2 +- .../DevToolsFeatureFlags.extension-oss.js | 2 +- .../src/devtools/ContextMenu/ContextMenu.js | 4 +- .../src/devtools/cache.js | 16 +- .../src/devtools/store.js | 12 +- .../src/devtools/utils.js | 2 +- .../devtools/views/Components/Components.js | 2 +- .../Components/InspectedElementContext.js | 2 +- .../Components/InspectedElementContextTree.js | 2 +- .../Components/InspectedElementHooksTree.js | 6 +- .../Components/InspectedElementStateTree.js | 2 +- .../Components/NativeStyleEditor/context.js | 2 +- .../views/Components/OwnersListContext.js | 8 +- .../src/devtools/views/Components/Tree.js | 2 +- .../devtools/views/Components/TreeContext.js | 53 +-- .../Components/ViewElementSourceContext.js | 2 +- .../src/devtools/views/DevTools.js | 6 +- .../src/devtools/views/Editor/EditorPane.js | 2 +- .../src/devtools/views/ErrorBoundary/cache.js | 12 +- .../InspectedElement/InspectedElementPane.js | 2 +- .../src/devtools/views/ModalDialog.js | 2 +- .../views/Profiler/CommitFlamegraph.js | 8 +- .../Profiler/CommitFlamegraphListItem.js | 4 +- .../devtools/views/Profiler/CommitRanked.js | 8 +- .../views/Profiler/CommitRankedListItem.js | 4 +- .../views/Profiler/CommitTreeBuilder.js | 50 +-- .../views/Profiler/FlamegraphChartBuilder.js | 2 +- .../views/Profiler/HoveredFiberInfo.js | 2 +- .../src/devtools/views/Profiler/Profiler.js | 2 +- .../views/Profiler/ProfilerContext.js | 6 +- .../Profiler/ProfilingImportExportButtons.js | 4 +- .../views/Profiler/RankedChartBuilder.js | 2 +- .../Profiler/SidebarSelectedFiberInfo.js | 4 +- .../views/Profiler/SnapshotCommitList.js | 6 +- .../views/Profiler/SnapshotCommitListItem.js | 4 +- .../views/Profiler/SnapshotSelector.js | 2 +- .../devtools/views/Profiler/WhatChanged.js | 2 +- .../useCommitFilteringAndNavigation.js | 2 +- .../views/Settings/ComponentsSettings.js | 14 +- .../views/Settings/SettingsContext.js | 20 +- .../views/Settings/SettingsModalContext.js | 2 +- .../views/SuspenseTab/SuspenseRects.js | 2 +- .../devtools/views/SuspenseTab/SuspenseTab.js | 2 +- .../views/SuspenseTab/SuspenseTreeContext.js | 4 +- .../src/devtools/views/TabBar.js | 2 +- .../src/devtools/views/context.js | 4 +- .../src/devtools/views/hooks.js | 4 +- .../src/devtools/views/utils.js | 2 +- .../src/dynamicImportCache.js | 8 +- packages/react-devtools-shared/src/hook.js | 24 +- .../src/hookNamesCache.js | 12 +- .../src/hooks/SourceMapConsumer.js | 16 +- .../parseHookNames/loadSourceAndMetadata.js | 14 +- .../parseHookNames/parseSourceAndMetadata.js | 8 +- .../react-devtools-shared/src/hydration.js | 18 +- .../src/inspectedElementCache.js | 10 +- .../src/inspectedElementMutableSource.js | 6 +- packages/react-devtools-shared/src/utils.js | 34 +- .../src/app/DeeplyNestedComponents/index.js | 2 +- .../app/InspectableElements/CustomHooks.js | 4 +- .../src/app/ToDoList/ListItem.js | 2 +- .../react-devtools-shell/src/app/devtools.js | 10 +- .../react-devtools-shell/src/app/index.js | 2 +- .../src/e2e-apps/ListApp.js | 2 +- .../src/e2e-regression/app-legacy.js | 2 +- .../src/e2e-regression/app.js | 2 +- packages/react-devtools-shell/src/e2e/app.js | 2 +- .../src/perf-regression/app.js | 2 +- .../src/EventTooltip.js | 4 +- .../react-devtools-timeline/src/Timeline.js | 2 +- .../src/TimelineContext.js | 2 +- .../src/TimelineSearchContext.js | 2 +- .../content-views/ComponentMeasuresView.js | 4 +- .../src/content-views/SuspenseEventsView.js | 2 +- .../src/content-views/utils/text.js | 2 +- .../src/createDataResourceFromImportedFile.js | 4 +- .../src/import-worker/preprocessData.js | 16 +- .../src/timelineCache.js | 12 +- .../src/utils/getBatchRange.js | 2 +- .../src/view-base/VerticalScrollView.js | 4 +- .../src/view-base/resizable/ResizableView.js | 4 +- .../src/client/DOMAccessibilityRoles.js | 4 +- .../src/client/DOMPropertyOperations.js | 20 +- .../src/client/ReactDOMComponent.js | 79 ++-- .../src/client/ReactDOMComponentTree.js | 92 ++--- .../src/client/ReactDOMContainer.js | 2 +- .../src/client/ReactDOMEventHandle.js | 14 +- .../src/client/ReactDOMInput.js | 22 +- .../src/client/ReactDOMSelect.js | 12 +- .../src/client/ReactDOMSrcObject.js | 2 +- .../src/client/ReactDOMTextarea.js | 12 +- .../src/client/ReactFiberConfigDOM.js | 383 +++++++++--------- .../src/client/ToStringValue.js | 2 +- .../src/client/inputValueTracking.js | 9 +- .../src/client/validateDOMNesting.js | 2 +- .../src/events/DOMEventProperties.js | 4 +- .../src/events/DOMPluginEventSystem.js | 20 +- .../src/events/EventRegistry.js | 2 +- .../src/events/ReactDOMEventReplaying.js | 24 +- .../src/events/forks/EventListener-www.js | 2 +- .../src/events/isEventSupported.js | 2 +- .../src/events/isTextInputElement.js | 2 +- .../src/events/plugins/ChangeEventPlugin.js | 16 +- .../events/plugins/EnterLeaveEventPlugin.js | 12 +- .../events/plugins/FormActionEventPlugin.js | 21 +- .../src/events/plugins/SelectEventPlugin.js | 2 +- .../src/events/plugins/SimpleEventPlugin.js | 4 +- .../ReactDOMFlightServerHostDispatcher.js | 4 +- .../server/ReactDOMServerExternalRuntime.js | 8 +- .../src/server/ReactFizzConfigDOM.js | 160 ++++---- .../src/server/escapeTextForBrowser.js | 2 +- .../src/shared/ReactDOMFormActions.js | 2 +- .../src/shared/sanitizeURL.js | 2 +- packages/react-dom/src/ReactDOMFB.js | 2 +- .../react-dom/src/ReactDOMSharedInternals.js | 2 +- .../src/ReactDOMSharedInternalsFB.js | 2 +- packages/react-dom/src/client/ReactDOMRoot.js | 6 +- .../react-dom/src/client/ReactDOMRootFB.js | 12 +- .../src/server/ReactDOMFizzServerBrowser.js | 16 +- .../src/server/ReactDOMFizzServerBun.js | 8 +- .../src/server/ReactDOMFizzServerEdge.js | 16 +- .../src/server/ReactDOMFizzServerNode.js | 20 +- .../src/server/ReactDOMFizzStaticBrowser.js | 8 +- .../src/server/ReactDOMFizzStaticEdge.js | 8 +- .../src/server/ReactDOMFizzStaticNode.js | 24 +- .../react-dom/src/test-utils/FizzTestUtils.js | 4 +- .../src/ReactFlightFBReferences.js | 4 +- .../src/ReactServerStreamConfigFB.js | 31 +- .../ReactFlightClientConfigBundlerFB.js | 16 +- .../src/client/ReactFlightDOMClientBrowser.js | 10 +- .../src/server/ReactFlightDOMServerNode.js | 18 +- .../react-markup/src/ReactMarkupClient.js | 4 +- .../react-markup/src/ReactMarkupServer.js | 8 +- packages/react-native-renderer/fabric.js | 2 +- .../src/ReactFabricComponentTree.js | 2 +- .../src/ReactFabricEventEmitter.js | 10 +- .../src/ReactFiberConfigFabric.js | 22 +- ...eactFiberConfigFabricWithViewTransition.js | 4 +- .../src/ReactNativeBridgeEventPlugin.js | 2 +- .../src/ReactNativeFiberInspector.js | 2 +- .../src/legacy-events/EventPluginRegistry.js | 2 +- .../ResponderTouchHistoryStore.js | 2 +- .../src/ReactNoopFlightServer.js | 4 +- .../src/ReactNoopServer.js | 2 +- .../src/createReactNoop.js | 28 +- .../react-reconciler/src/ReactChildFiber.js | 54 +-- .../src/ReactFiberApplyGesture.js | 6 +- .../src/ReactFiberAsyncAction.js | 8 +- .../src/ReactFiberAsyncDispatcher.js | 6 +- .../src/ReactFiberBeginWork.js | 78 ++-- .../src/ReactFiberCacheComponent.js | 8 +- .../src/ReactFiberCallUserSpace.js | 36 +- .../src/ReactFiberClassComponent.js | 6 +- .../src/ReactFiberClassUpdateQueue.js | 20 +- .../src/ReactFiberCommitEffects.js | 18 +- .../src/ReactFiberCommitWork.js | 100 ++--- .../src/ReactFiberCompleteWork.js | 36 +- .../src/ReactFiberComponentStack.js | 4 +- .../src/ReactFiberConcurrentUpdates.js | 14 +- .../src/ReactFiberDuplicateViewTransitions.js | 8 +- .../src/ReactFiberErrorLogger.js | 4 +- .../react-reconciler/src/ReactFiberHooks.js | 153 ++++--- .../src/ReactFiberHostContext.js | 2 +- .../src/ReactFiberHotReloading.js | 2 +- .../src/ReactFiberHydrationContext.js | 6 +- .../src/ReactFiberHydrationDiffs.js | 8 +- .../src/ReactFiberLegacyContext.js | 2 +- .../src/ReactFiberNewContext.js | 2 +- .../src/ReactFiberPerformanceTrack.js | 8 +- .../src/ReactFiberReconciler.js | 10 +- .../react-reconciler/src/ReactFiberRoot.js | 4 +- .../react-reconciler/src/ReactFiberScope.js | 2 +- .../src/ReactFiberThenable.js | 20 +- .../react-reconciler/src/ReactFiberThrow.js | 12 +- .../src/ReactFiberTransition.js | 6 +- .../src/ReactFiberTreeReflection.js | 2 +- .../src/ReactFiberViewTransitionComponent.js | 2 +- .../src/ReactFiberWorkLoop.js | 60 +-- .../src/ReactProfilerTimer.js | 4 +- .../src/ReactStrictModeWarnings.js | 2 +- .../src/ReactTestSelectors.js | 36 +- .../src/getComponentNameFromFiber.js | 10 +- .../react-refresh/src/ReactFreshRuntime.js | 4 +- .../src/ReactFlightESMReferences.js | 4 +- .../ReactFlightClientConfigBundlerESM.js | 12 +- .../src/client/ReactFlightDOMClientBrowser.js | 10 +- .../src/server/ReactFlightDOMServerNode.js | 26 +- .../src/ReactDOMServerFB.js | 2 +- .../src/ReactFlightParcelReferences.js | 4 +- .../ReactFlightClientConfigBundlerParcel.js | 2 +- .../src/client/ReactFlightDOMClientBrowser.js | 10 +- .../src/client/ReactFlightDOMClientEdge.js | 10 +- .../src/server/ReactFlightDOMServerBrowser.js | 10 +- .../src/server/ReactFlightDOMServerEdge.js | 12 +- .../src/server/ReactFlightDOMServerNode.js | 42 +- .../src/ReactFlightTurbopackReferences.js | 26 +- ...ReactFlightClientConfigBundlerTurbopack.js | 6 +- ...ightClientConfigBundlerTurbopackBrowser.js | 8 +- .../src/client/ReactFlightDOMClientBrowser.js | 10 +- .../src/client/ReactFlightDOMClientEdge.js | 10 +- .../src/server/ReactFlightDOMServerBrowser.js | 10 +- .../src/server/ReactFlightDOMServerEdge.js | 12 +- .../src/server/ReactFlightDOMServerNode.js | 42 +- .../src/ReactFlightUnbundledNodeRegister.js | 8 +- .../src/ReactFlightUnbundledReferences.js | 22 +- .../ReactFlightClientConfigBundlerNode.js | 8 +- .../src/client/ReactFlightDOMClientEdge.js | 10 +- .../src/server/ReactFlightDOMServerNode.js | 42 +- .../src/ReactFlightWebpackNodeRegister.js | 8 +- .../src/ReactFlightWebpackPlugin.js | 2 +- .../src/ReactFlightWebpackReferences.js | 26 +- .../ReactFlightClientConfigBundlerWebpack.js | 6 +- ...FlightClientConfigBundlerWebpackBrowser.js | 8 +- .../src/client/ReactFlightDOMClientBrowser.js | 10 +- .../src/client/ReactFlightDOMClientEdge.js | 10 +- .../src/server/ReactFlightDOMServerBrowser.js | 10 +- .../src/server/ReactFlightDOMServerEdge.js | 12 +- .../src/server/ReactFlightDOMServerNode.js | 42 +- .../src/ReactFizzAsyncDispatcher.js | 4 +- .../src/ReactFizzCallUserSpace.js | 12 +- .../src/ReactFizzClassComponent.js | 2 +- .../src/ReactFizzComponentStack.js | 8 +- packages/react-server/src/ReactFizzHooks.js | 28 +- .../src/ReactFizzLegacyContext.js | 2 +- packages/react-server/src/ReactFizzServer.js | 115 +++--- .../react-server/src/ReactFizzThenable.js | 18 +- .../src/ReactFlightActionServer.js | 4 +- .../src/ReactFlightCallUserSpace.js | 12 +- packages/react-server/src/ReactFlightHooks.js | 38 +- .../src/ReactFlightReplyServer.js | 88 ++-- .../react-server/src/ReactFlightServer.js | 217 +++++----- .../src/ReactFlightServerConfigDebugNode.js | 34 +- .../ReactFlightServerTemporaryReferences.js | 4 +- .../src/ReactFlightStackConfigV8.js | 6 +- .../react-server/src/ReactFlightThenable.js | 14 +- .../src/ReactServerStreamConfigBrowser.js | 9 +- .../src/ReactServerStreamConfigEdge.js | 9 +- .../src/ReactServerStreamConfigFB.js | 2 +- .../src/ReactServerStreamConfigNode.js | 29 +- .../src/flight/ReactFlightAsyncDispatcher.js | 6 +- .../src/forks/ReactFizzConfig.custom.js | 2 +- .../src/forks/ReactFizzConfig.dom-edge.js | 2 +- .../src/forks/ReactFizzConfig.dom-fb.js | 2 +- .../src/forks/ReactFizzConfig.dom-legacy.js | 2 +- .../src/forks/ReactFizzConfig.dom.js | 2 +- .../src/forks/ReactFizzConfig.markup.js | 2 +- .../src/forks/ReactFizzConfig.noop.js | 2 +- .../forks/ReactFlightServerConfig.custom.js | 4 +- ...ReactFlightServerConfig.dom-browser-esm.js | 4 +- .../ReactFlightServerConfig.dom-browser-fb.js | 4 +- ...ctFlightServerConfig.dom-browser-parcel.js | 4 +- ...lightServerConfig.dom-browser-turbopack.js | 4 +- .../ReactFlightServerConfig.dom-browser.js | 4 +- .../forks/ReactFlightServerConfig.dom-bun.js | 4 +- ...ReactFlightServerConfig.dom-edge-parcel.js | 4 +- ...ctFlightServerConfig.dom-edge-turbopack.js | 4 +- .../forks/ReactFlightServerConfig.dom-edge.js | 4 +- .../ReactFlightServerConfig.dom-legacy.js | 4 +- .../ReactFlightServerConfig.dom-node-esm.js | 2 +- .../ReactFlightServerConfig.dom-node-fb.js | 4 +- ...ReactFlightServerConfig.dom-node-parcel.js | 2 +- ...ctFlightServerConfig.dom-node-turbopack.js | 2 +- ...ctFlightServerConfig.dom-node-unbundled.js | 2 +- .../forks/ReactFlightServerConfig.dom-node.js | 2 +- .../forks/ReactFlightServerConfig.markup.js | 4 +- .../src/forks/ReactFlightServerConfig.noop.js | 4 +- .../src/ReactSuspenseTestUtils.js | 2 +- .../src/ReactFiberConfigTestHost.js | 4 +- .../src/ReactTestRenderer.js | 54 ++- packages/react/src/ReactAct.js | 4 +- packages/react/src/ReactCacheImpl.js | 4 +- packages/react/src/ReactChildren.js | 28 +- packages/react/src/ReactContext.js | 4 +- packages/react/src/ReactHooks.js | 2 +- packages/react/src/ReactLazy.js | 18 +- .../react/src/ReactSharedInternalsClient.js | 6 +- .../react/src/ReactSharedInternalsServer.js | 6 +- packages/react/src/ReactStartTransition.js | 4 +- packages/scheduler/src/forks/Scheduler.js | 4 +- .../scheduler/src/forks/SchedulerNative.js | 2 +- .../scheduler/src/forks/SchedulerPostTask.js | 2 +- packages/shared/CheckStringCoercion.js | 6 +- packages/shared/DefaultPrepareStackTrace.js | 2 +- .../shared/ReactPerformanceTrackProperties.js | 2 +- packages/shared/ReactSerializationErrors.js | 6 +- packages/shared/ReactSymbols.js | 4 +- .../forks/ReactFeatureFlags.native-fb.js | 4 +- .../forks/ReactFeatureFlags.native-oss.js | 2 +- .../forks/ReactFeatureFlags.test-renderer.js | 2 +- ...actFeatureFlags.test-renderer.native-fb.js | 2 +- .../ReactFeatureFlags.test-renderer.www.js | 2 +- .../shared/forks/ReactFeatureFlags.www.js | 2 +- packages/shared/getComponentNameFromType.js | 16 +- .../src/useSyncExternalStoreWithSelector.js | 4 +- scripts/flags/flags.js | 15 +- scripts/flow/environment.js | 40 +- yarn.lock | 36 +- 330 files changed, 2423 insertions(+), 2422 deletions(-) diff --git a/package.json b/package.json index c247d21d6c0d..db5b359c7a27 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.307.1", - "flow-remove-types": "^2.307.1", + "flow-bin": "^0.317.0", + "flow-remove-types": "^2.317.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 1ab1c96f9694..087503853e71 100644 --- a/packages/react-cache/src/LRU.js +++ b/packages/react-cache/src/LRU.js @@ -56,21 +56,21 @@ export function createLRU(limit: number): LRU { function deleteLeastRecentlyUsedEntries(targetSize: number) { // Delete entries from the cache, starting from the end of the list. if (first !== null) { - const resolvedFirst: Entry = (first: any); + const resolvedFirst: Entry = first as any; let last: null | Entry = resolvedFirst.previous; while (size > targetSize && last !== null) { const onDelete = last.onDelete; const previous = last.previous; - last.onDelete = (null: any); + last.onDelete = null as any; // Remove from the list - last.previous = last.next = (null: any); + last.previous = last.next = null as any; if (last === first) { // Reached the head of the list. first = last = null; } else { - (first: any).previous = previous; - previous.next = (first: any); + (first as any).previous = previous; + previous.next = first as any; last = previous; } @@ -88,8 +88,8 @@ export function createLRU(limit: number): LRU { const entry = { value, onDelete, - next: (null: any), - previous: (null: any), + next: null as any, + previous: null as any, }; if (first === null) { entry.previous = entry.next = entry; @@ -118,7 +118,7 @@ export function createLRU(limit: number): LRU { // $FlowFixMe[invalid-compare] if (next !== null) { // Entry already cached - const resolvedFirst: Entry = (first: any); + const resolvedFirst: Entry = first as any; if (first !== entry) { // Remove from current position const previous = entry.previous; diff --git a/packages/react-cache/src/ReactCacheOld.js b/packages/react-cache/src/ReactCacheOld.js index 7ea17286679d..5485505af7e2 100644 --- a/packages/react-cache/src/ReactCacheOld.js +++ b/packages/react-cache/src/ReactCacheOld.js @@ -107,14 +107,14 @@ function accessResult( thenable.then( value => { if (newResult.status === Pending) { - const resolvedResult: ResolvedResult = (newResult: any); + const resolvedResult: ResolvedResult = newResult as any; resolvedResult.status = Resolved; resolvedResult.value = value; } }, error => { if (newResult.status === Pending) { - const rejectedResult: RejectedResult = (newResult: any); + const rejectedResult: RejectedResult = newResult as any; rejectedResult.status = Rejected; rejectedResult.value = error; } @@ -128,7 +128,7 @@ function accessResult( entriesForResource.set(key, newEntry); return newResult; } else { - return (lru.access(entry): any); + return lru.access(entry) as any; } } @@ -147,7 +147,7 @@ export function unstable_createResource( maybeHashInput?: I => K, ): Resource { const hashInput: I => K = - maybeHashInput !== undefined ? maybeHashInput : (identityHashFn: any); + maybeHashInput !== undefined ? maybeHashInput : (identityHashFn as any); const resource = { read(input: I): V { @@ -171,7 +171,7 @@ export function unstable_createResource( } default: // Should be unreachable - return (undefined: any); + return undefined as any; } }, diff --git a/packages/react-client/src/ReactFlightClient.js b/packages/react-client/src/ReactFlightClient.js index e8af45adf713..7ac416bbe6b6 100644 --- a/packages/react-client/src/ReactFlightClient.js +++ b/packages/react-client/src/ReactFlightClient.js @@ -116,7 +116,7 @@ import type {SharedStateClient} from 'react/src/ReactSharedInternalsClient'; // client both in the RSC environment, in the SSR environments as well as the // browser client. We should probably have a separate RSC build. This is DEV // only though. -const ReactSharedInteralsServer: void | SharedStateServer = (React: any) +const ReactSharedInteralsServer: void | SharedStateServer = (React as any) .__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; const ReactSharedInternals: SharedStateServer | SharedStateClient = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE || @@ -254,7 +254,7 @@ function ReactPromise(status: any, value: any, reason: any) { } } // We subclass Promise.prototype so that we get other methods like .catch -ReactPromise.prototype = (Object.create(Promise.prototype): any); +ReactPromise.prototype = Object.create(Promise.prototype) as any; // TODO: This doesn't return a new Promise chain unlike the real .then ReactPromise.prototype.then = function ( this: SomeChunk, @@ -304,15 +304,15 @@ ReactPromise.prototype.then = function ( case BLOCKED: if (typeof resolve === 'function') { if (chunk.value === null) { - chunk.value = ([]: Array mixed)>); + chunk.value = [] as Array mixed)>; } chunk.value.push(resolve); } if (typeof reject === 'function') { if (chunk.reason === null) { - chunk.reason = ([]: Array< + chunk.reason = [] as Array< InitializationReference | (mixed => mixed), - >); + >; } chunk.reason.push(reject); } @@ -394,7 +394,7 @@ function unwrapWeakResponse(weakResponse: WeakResponse): Response { } return response; } else { - return (weakResponse: any); // In prod we just use the real Response directly. + return weakResponse as any; // In prod we just use the real Response directly. } } @@ -402,7 +402,7 @@ function getWeakResponse(response: Response): WeakResponse { if (__DEV__) { return response._weakResponse; } else { - return (response: any); // In prod we just use the real Response directly. + return response as any; // In prod we just use the real Response directly. } } @@ -437,7 +437,7 @@ function readChunk(chunk: SomeChunk): T { case BLOCKED: case HALTED: // eslint-disable-next-line no-throw-literal - throw ((chunk: any): Thenable); + throw chunk as any as Thenable; default: throw chunk.reason; } @@ -446,7 +446,7 @@ function readChunk(chunk: SomeChunk): T { export function getRoot(weakResponse: WeakResponse): Thenable { const response = unwrapWeakResponse(weakResponse); const chunk = getChunk(response, 0); - return (chunk: any); + return chunk as any; } function createPendingChunk(response: Response): PendingChunk { @@ -547,7 +547,7 @@ function moveDebugInfoFromChunkToInnerValue( debugInfo, ); } else if (!Object.isFrozen(resolvedValue)) { - Object.defineProperty((resolvedValue: any), '_debugInfo', { + Object.defineProperty(resolvedValue as any, '_debugInfo', { configurable: false, enumerable: false, writable: true, @@ -665,9 +665,9 @@ function wakeChunkIfInitialized( } } // The status might have changed after fulfilling the reference. - switch ((chunk: SomeChunk).status) { + switch ((chunk as SomeChunk).status) { case INITIALIZED: - const initializedChunk: InitializedChunk = (chunk: any); + const initializedChunk: InitializedChunk = chunk as any; wakeChunk( response, resolveListeners, @@ -721,7 +721,7 @@ function triggerErrorOnChunk( if (chunk.status !== PENDING && chunk.status !== BLOCKED) { // If we get more data to an already resolved ID, we assume that it's // a stream chunk since any other row shouldn't have more than one entry. - const streamChunk: InitializedStreamChunk = (chunk: any); + const streamChunk: InitializedStreamChunk = chunk as any; const controller = streamChunk.reason; // $FlowFixMe[incompatible-type]: The error method should accept mixed. controller.error(error); @@ -736,7 +736,7 @@ function triggerErrorOnChunk( const prevHandler = initializingHandler; const prevChunk = initializingChunk; initializingHandler = null; - const cyclicChunk: BlockedChunk = (chunk: any); + const cyclicChunk: BlockedChunk = chunk as any; cyclicChunk.status = BLOCKED; cyclicChunk.value = null; cyclicChunk.reason = null; @@ -761,7 +761,7 @@ function triggerErrorOnChunk( } } - const erroredChunk: ErroredChunk = (chunk: any); + const erroredChunk: ErroredChunk = chunk as any; erroredChunk.status = ERRORED; erroredChunk.reason = error; if (listeners !== null) { @@ -861,7 +861,7 @@ function resolveModelChunk( if (chunk.status !== PENDING) { // If we get more data to an already resolved ID, we assume that it's // a stream chunk since any other row shouldn't have more than one entry. - const streamChunk: InitializedStreamChunk = (chunk: any); + const streamChunk: InitializedStreamChunk = chunk as any; const controller = streamChunk.reason; controller.enqueueModel(value); return; @@ -869,7 +869,7 @@ function resolveModelChunk( releasePendingChunk(response, chunk); const resolveListeners = chunk.value; const rejectListeners = chunk.reason; - const resolvedChunk: ResolvedModelChunk = (chunk: any); + const resolvedChunk: ResolvedModelChunk = chunk as any; resolvedChunk.status = RESOLVED_MODEL; resolvedChunk.value = value; resolvedChunk.reason = response; @@ -895,7 +895,7 @@ function resolveModuleChunk( releasePendingChunk(response, chunk); const resolveListeners = chunk.value; const rejectListeners = chunk.reason; - const resolvedChunk: ResolvedModuleChunk = (chunk: any); + const resolvedChunk: ResolvedModuleChunk = chunk as any; resolvedChunk.status = RESOLVED_MODULE; resolvedChunk.value = value; resolvedChunk.reason = null; @@ -960,7 +960,7 @@ function initializeDebugChunk( } // Initializing the model for the first time. initializeModelChunk(debugChunk); - const initializedChunk = ((debugChunk: any): SomeChunk); + const initializedChunk = debugChunk as any as SomeChunk; switch (initializedChunk.status) { case INITIALIZED: { debugInfo[idx] = initializeDebugInfo( @@ -1028,7 +1028,7 @@ function initializeModelChunk(chunk: ResolvedModelChunk): void { // We go to the BLOCKED state until we've fully resolved this. // We do this before parsing in case we try to initialize the same chunk // while parsing the model. Such as in a cyclic reference. - const cyclicChunk: BlockedChunk = (chunk: any); + const cyclicChunk: BlockedChunk = chunk as any; cyclicChunk.status = BLOCKED; cyclicChunk.value = null; cyclicChunk.reason = null; @@ -1075,7 +1075,7 @@ function initializeModelChunk(chunk: ResolvedModelChunk): void { return; } } - const initializedChunk: InitializedChunk = (chunk: any); + const initializedChunk: InitializedChunk = chunk as any; initializedChunk.status = INITIALIZED; initializedChunk.value = value; initializedChunk.reason = null; @@ -1084,7 +1084,7 @@ function initializeModelChunk(chunk: ResolvedModelChunk): void { processChunkDebugInfo(response, initializedChunk, value); } } catch (error) { - const erroredChunk: ErroredChunk = (chunk: any); + const erroredChunk: ErroredChunk = chunk as any; erroredChunk.status = ERRORED; erroredChunk.reason = error; } finally { @@ -1098,12 +1098,12 @@ function initializeModelChunk(chunk: ResolvedModelChunk): void { function initializeModuleChunk(chunk: ResolvedModuleChunk): void { try { const value: T = requireModule(chunk.value); - const initializedChunk: InitializedChunk = (chunk: any); + const initializedChunk: InitializedChunk = chunk as any; initializedChunk.status = INITIALIZED; initializedChunk.value = value; initializedChunk.reason = null; } catch (error) { - const erroredChunk: ErroredChunk = (chunk: any); + const erroredChunk: ErroredChunk = chunk as any; erroredChunk.status = ERRORED; erroredChunk.reason = error; } @@ -1240,7 +1240,7 @@ function initializeElement( element._debugStack = normalizedStackTrace; let task: null | ConsoleTask = null; if (supportsCreateTask && stack !== null) { - const createTaskFn = (console: any).createTask.bind( + const createTaskFn = (console as any).createTask.bind( console, getTaskName(element.type), ); @@ -1322,19 +1322,19 @@ function createElement( let element: any; if (__DEV__) { // `ref` is non-enumerable in dev - element = ({ + element = { $$typeof: REACT_ELEMENT_TYPE, type, key, props, _owner: owner === undefined ? null : owner, - }: any); + } as any; Object.defineProperty(element, 'ref', { enumerable: false, get: nullRefGetter, }); } else { - element = ({ + element = { // This tag allows us to uniquely identify this as a React Element $$typeof: REACT_ELEMENT_TYPE, @@ -1342,16 +1342,16 @@ function createElement( key, ref: null, props, - }: any); + } as any; } if (__DEV__) { // We don't really need to add any of these but keeping them for good measure. // Unfortunately, _store is enumerable in jest matchers so for equality to // work, I need to keep it or make _store non-enumerable in the other file. - element._store = ({}: { + element._store = {} as { validated?: number, - }); + }; Object.defineProperty(element._store, 'validated', { configurable: false, enumerable: false, @@ -1463,7 +1463,7 @@ function getChunk(response: Response, id: number): SomeChunk { // For partial streams, chunks accessed after close should be HALTED // (never resolve). chunk = createPendingChunk(response); - const haltedChunk: HaltedChunk = (chunk: any); + const haltedChunk: HaltedChunk = chunk as any; haltedChunk.status = HALTED; haltedChunk.value = null; haltedChunk.reason = null; @@ -1673,7 +1673,7 @@ function fulfillReference( return; } const resolveListeners = chunk.value; - const initializedChunk: InitializedChunk = (chunk: any); + const initializedChunk: InitializedChunk = chunk as any; initializedChunk.status = INITIALIZED; initializedChunk.value = handler.value; initializedChunk.reason = handler.reason; // Used by streaming chunks @@ -1762,7 +1762,7 @@ function waitForReference( // If it's still pending that suggests that it was referencing an object in the debug // channel, but no debug channel was wired up so it's missing. In this case we can just // drop the debug info instead of halting the whole stream. - return (null: any); + return null as any; } } @@ -1805,7 +1805,7 @@ function waitForReference( } // Return a place holder value for now. - return (null: any); + return null as any; } function loadServerReference, T>( @@ -1840,7 +1840,7 @@ function loadServerReference, T>( let promise: null | Thenable = preloadModule(serverReference); if (!promise) { if (!metaData.bound) { - const resolvedValue = (requireModule(serverReference): any); + const resolvedValue = requireModule(serverReference) as any; registerBoundServerReference( resolvedValue, metaData.id, @@ -1871,11 +1871,11 @@ function loadServerReference, T>( } function fulfill(): void { - let resolvedValue = (requireModule(serverReference): any); + let resolvedValue = requireModule(serverReference) as any; if (metaData.bound) { // This promise is coming from us and should have initilialized by now. - const boundArgs: Array = (metaData.bound: any).value.slice(0); + const boundArgs: Array = (metaData.bound as any).value.slice(0); boundArgs.unshift(null); // this resolvedValue = resolvedValue.bind.apply(resolvedValue, boundArgs); } @@ -1927,7 +1927,7 @@ function loadServerReference, T>( return; } const resolveListeners = chunk.value; - const initializedChunk: InitializedChunk = (chunk: any); + const initializedChunk: InitializedChunk = chunk as any; initializedChunk.status = INITIALIZED; initializedChunk.value = handler.value; initializedChunk.reason = null; @@ -1990,7 +1990,7 @@ function loadServerReference, T>( promise.then(fulfill, reject); // Return a place holder value for now. - return (null: any); + return null as any; } function resolveLazy(value: any): mixed { @@ -2025,7 +2025,7 @@ function transferReferencedDebugInfo( for (let i = 0; i < referencedDebugInfo.length; ++i) { const debugInfoEntry = referencedDebugInfo[i]; if (debugInfoEntry.name != null) { - (debugInfoEntry: ReactComponentInfo); + debugInfoEntry as ReactComponentInfo; // We're not transferring Component info since we use Component info // in Debug info to fill in gaps between Fibers for the parent stack. } else { @@ -2112,7 +2112,7 @@ function getOutlinedModel( errored: false, }; } - return (null: any); + return null as any; } default: { // This is an error. Instead of erroring directly, we're going to encode this on @@ -2131,7 +2131,7 @@ function getOutlinedModel( errored: true, }; } - return (null: any); + return null as any; } } } @@ -2209,7 +2209,7 @@ function getOutlinedModel( errored: false, }; } - return (null: any); + return null as any; } default: // This is an error. Instead of erroring directly, we're going to encode this on @@ -2229,7 +2229,7 @@ function getOutlinedModel( }; } // Placeholder - return (null: any); + return null as any; } } @@ -2651,7 +2651,7 @@ function parseModelTuple( response: Response, value: {+[key: string]: JSONValue} | $ReadOnlyArray, ): any { - const tuple: [mixed, mixed, mixed, mixed] = (value: any); + const tuple: [mixed, mixed, mixed, mixed] = value as any; if (tuple[0] === REACT_ELEMENT_TYPE) { // TODO: Consider having React just directly accept these arrays as elements. @@ -2661,9 +2661,9 @@ function parseModelTuple( tuple[1], tuple[2], tuple[3], - __DEV__ ? (tuple: any)[4] : null, - __DEV__ ? (tuple: any)[5] : null, - __DEV__ ? (tuple: any)[6] : 0, + __DEV__ ? (tuple as any)[4] : null, + __DEV__ ? (tuple as any)[5] : null, + __DEV__ ? (tuple as any)[6] : 0, ); } return value; @@ -2730,7 +2730,7 @@ function ResponseInstance( ReactSharedInteralsServer === undefined || ReactSharedInteralsServer.A === null ? null - : (ReactSharedInteralsServer.A.getOwner(): any); + : (ReactSharedInteralsServer.A.getOwner() as any); this._debugRootOwner = rootOwner; this._debugRootStack = @@ -2746,7 +2746,7 @@ function ResponseInstance( // elements created by the server. We use the "use server" string to indicate that // this is where we enter the server from the client. // TODO: Make this string configurable. - this._debugRootTask = (console: any).createTask( + this._debugRootTask = (console as any).createTask( '"use ' + rootEnv.toLowerCase() + '"', ); } @@ -2850,19 +2850,19 @@ export function createStreamState( weakResponse: WeakResponse, // DEV-only streamDebugValue: mixed, // DEV-only ): StreamState { - const streamState: StreamState = (({ + const streamState: StreamState = { _rowState: 0, _rowID: 0, _rowTag: 0, _rowLength: 0, _buffer: [], - }: Omit): any); + } as Omit as any; if (__DEV__ && enableAsyncDebugInfo) { const response = unwrapWeakResponse(weakResponse); // Create an entry for the I/O to load the stream itself. const debugValuePromise = Promise.resolve(streamDebugValue); - (debugValuePromise: any).status = 'fulfilled'; - (debugValuePromise: any).value = streamDebugValue; + (debugValuePromise as any).status = 'fulfilled'; + (debugValuePromise as any).value = streamDebugValue; streamState._debugInfo = { name: 'rsc stream', start: response._debugStartTime, @@ -2896,7 +2896,7 @@ function incrementChunkDebugInfo( const debugInfo: ReactIOInfo = streamState._debugInfo; const endTime = performance.now(); const previousEndTime = debugInfo.end; - const newByteLength = ((debugInfo.byteSize: any): number) + chunkLength; + const newByteLength = (debugInfo.byteSize as any as number) + chunkLength; if ( newByteLength > streamState._debugTargetChunkSize || endTime > previousEndTime + 10 @@ -2942,7 +2942,7 @@ function addAsyncInfo(chunk: SomeChunk, asyncInfo: ReactAsyncInfo): void { } else if (!Object.isFrozen(value)) { // TODO: Debug info is dropped for frozen elements. See the TODO in // moveDebugInfoFromChunkToInnerValue. - Object.defineProperty((value: any), '_debugInfo', { + Object.defineProperty(value as any, '_debugInfo', { configurable: false, enumerable: false, writable: true, @@ -2988,7 +2988,7 @@ function resolveDebugHalt(response: Response, id: number): void { return; } releasePendingChunk(response, chunk); - const haltedChunk: HaltedChunk = (chunk: any); + const haltedChunk: HaltedChunk = chunk as any; haltedChunk.status = HALTED; haltedChunk.value = null; haltedChunk.reason = null; @@ -3030,7 +3030,7 @@ function resolveText( if (chunk && chunk.status !== PENDING) { // If we get more data to an already resolved ID, we assume that it's // a stream chunk since any other row shouldn't have more than one entry. - const streamChunk: InitializedStreamChunk = (chunk: any); + const streamChunk: InitializedStreamChunk = chunk as any; const controller = streamChunk.reason; controller.enqueueValue(text); return; @@ -3056,7 +3056,7 @@ function resolveBuffer( if (chunk && chunk.status !== PENDING) { // If we get more data to an already resolved ID, we assume that it's // a stream chunk since any other row shouldn't have more than one entry. - const streamChunk: InitializedStreamChunk = (chunk: any); + const streamChunk: InitializedStreamChunk = chunk as any; const controller = streamChunk.reason; controller.enqueueValue(buffer); return; @@ -3109,7 +3109,7 @@ function resolveModule( releasePendingChunk(response, chunk); // This can't actually happen because we don't have any forward // references to modules. - blockedChunk = (chunk: any); + blockedChunk = chunk as any; blockedChunk.status = BLOCKED; } if (__DEV__) { @@ -3171,7 +3171,7 @@ function resolveStream>( const prevHandler = initializingHandler; const prevChunk = initializingChunk; initializingHandler = null; - const cyclicChunk: BlockedChunk = (chunk: any); + const cyclicChunk: BlockedChunk = chunk as any; cyclicChunk.status = BLOCKED; cyclicChunk.value = null; cyclicChunk.reason = null; @@ -3198,12 +3198,12 @@ function resolveStream>( } } - const resolvedChunk: InitializedStreamChunk = (chunk: any); + const resolvedChunk: InitializedStreamChunk = chunk as any; resolvedChunk.status = INITIALIZED; resolvedChunk.value = stream; resolvedChunk.reason = controller; if (resolveListeners !== null) { - wakeChunk(response, resolveListeners, chunk.value, (chunk: any)); + wakeChunk(response, resolveListeners, chunk.value, chunk as any); } else { if (__DEV__) { processChunkDebugInfo(response, resolvedChunk, stream); @@ -3217,7 +3217,7 @@ function startReadableStream( type: void | 'bytes', streamState: StreamState, ): void { - let controller: ReadableStreamController = (null: any); + let controller: ReadableStreamController = null as any; let closed = false; const stream = new ReadableStream({ type: type, @@ -3252,7 +3252,7 @@ function startReadableStream( } else { chunk.then( v => controller.enqueue(v), - e => controller.error((e: any)), + e => controller.error(e as any), ); previousBlockedChunk = chunk; } @@ -3262,7 +3262,7 @@ function startReadableStream( const chunk: SomeChunk = createPendingChunk(response); chunk.then( v => controller.enqueue(v), - e => controller.error((e: any)), + e => controller.error(e as any), ); previousBlockedChunk = chunk; blockedChunk.then(function () { @@ -3301,7 +3301,7 @@ function startReadableStream( const blockedChunk = previousBlockedChunk; // We shouldn't get any more enqueues after this so we can set it back to null. previousBlockedChunk = null; - blockedChunk.then(() => controller.error((error: any))); + blockedChunk.then(() => controller.error(error as any)); } }, }; @@ -3323,7 +3323,7 @@ function createIterator( // TODO: The iterator could inherit the AsyncIterator prototype which is not exposed as // a global but exists as a prototype of an AsyncGenerator. However, it's not needed // to satisfy the iterable protocol. - (iterator: any)[ASYNC_ITERATOR] = asyncIterator; + (iterator as any)[ASYNC_ITERATOR] = asyncIterator; return iterator; } @@ -3345,13 +3345,13 @@ function startAsyncIterable( false, ); } else { - const chunk: PendingChunk> = (buffer[ + const chunk: PendingChunk> = buffer[ nextWriteIndex - ]: any); + ] as any; const resolveListeners = chunk.value; const rejectListeners = chunk.reason; const initializedChunk: InitializedChunk> = - (chunk: any); + chunk as any; initializedChunk.status = INITIALIZED; initializedChunk.value = {done: false, value: value}; initializedChunk.reason = null; @@ -3428,7 +3428,7 @@ function startAsyncIterable( }, }; - const iterable: $AsyncIterable = ({}: any); + const iterable: $AsyncIterable = {} as any; // $FlowFixMe[cannot-write] iterable[ASYNC_ITERATOR] = (): $AsyncIterator => { let nextReadIndex = 0; @@ -3484,7 +3484,7 @@ function stopStream( response._weakResponse.response = null; } } - const streamChunk: InitializedStreamChunk = (chunk: any); + const streamChunk: InitializedStreamChunk = chunk as any; const controller = streamChunk.reason; controller.close(row === '' ? '"$undefined"' : row); } @@ -3533,7 +3533,7 @@ function resolveErrorDev( cause: reviveModel( response, // $FlowFixMe[incompatible-type] -- Flow thinks `cause` in `cause?: JSONValue` can be undefined after `in` check. - (errorInfo.cause: JSONValue), + errorInfo.cause as JSONValue, errorInfo, 'cause', ), @@ -3547,7 +3547,7 @@ function resolveErrorDev( ? reviveModel( response, // $FlowFixMe[incompatible-type] - (errorInfo.errors: JSONValue), + errorInfo.errors as JSONValue, errorInfo, 'errors', ) @@ -3597,8 +3597,8 @@ function resolveErrorDev( error = ownerTask.run(callStack); } - (error: any).name = name; - (error: any).environmentName = env; + (error as any).name = name; + (error as any).environmentName = env; return error; } @@ -3617,8 +3617,8 @@ function resolveErrorModel( } else { error = resolveErrorProd(response); } - (error: any).digest = errorInfo.digest; - const errorWithDigest: ErrorWithDigest = (error: any); + (error as any).digest = errorInfo.digest; + const errorWithDigest: ErrorWithDigest = error as any; if (!chunk) { const newChunk: ErroredChunk = createErrorChunk( response, @@ -3645,12 +3645,12 @@ function resolveHint( dispatchHint(code, hintModel); } -const supportsCreateTask = __DEV__ && !!(console: any).createTask; +const supportsCreateTask = __DEV__ && !!(console as any).createTask; type FakeFunction = (() => T) => T; const fakeFunctionCache: Map> = __DEV__ ? new Map() - : (null: any); + : (null as any); let fakeFunctionIdx = 0; function createFakeFunction( @@ -3882,7 +3882,7 @@ function getRootTask( // If the root most owner component is itself in a different environment than the requested // environment then we create an extra task to indicate that we're transitioning into it. // Like if one environment just requests another environment. - const createTaskFn = (console: any).createTask.bind( + const createTaskFn = (console as any).createTask.bind( console, '"use ' + childEnvironmentName.toLowerCase() + '"', ); @@ -3935,10 +3935,10 @@ function initializeFakeTask( ? '"use ' + env.toLowerCase() + '"' : // Some unfortunate pattern matching to refine the type. debugInfo.key !== undefined - ? getServerComponentTaskName(((debugInfo: any): ReactComponentInfo)) + ? getServerComponentTaskName(debugInfo as any as ReactComponentInfo) : debugInfo.name !== undefined - ? getIOInfoTaskName(((debugInfo: any): ReactIOInfo)) - : getAsyncInfoTaskName(((debugInfo: any): ReactAsyncInfo)); + ? getIOInfoTaskName(debugInfo as any as ReactIOInfo) + : getAsyncInfoTaskName(debugInfo as any as ReactAsyncInfo); // $FlowFixMe[cannot-write]: We consider this part of initialization. return (debugInfo.debugTask = buildFakeTask( response, @@ -3958,7 +3958,7 @@ function buildFakeTask( env: string, useEnclosingLine: boolean, ): ConsoleTask { - const createTaskFn = (console: any).createTask.bind(console, taskName); + const createTaskFn = (console as any).createTask.bind(console, taskName); const callStack = buildFakeCallStack( response, stack, @@ -4003,8 +4003,8 @@ const createFakeJSXCallStackInDEV: ( ? // We use this technique to trick minifiers to preserve the function name. (createFakeJSXCallStack.react_stack_bottom_frame.bind( createFakeJSXCallStack, - ): any) - : (null: any); + ) as any) + : (null as any); /** @noinline */ function fakeJSXCallSite() { @@ -4120,7 +4120,7 @@ function resolveDebugModel( initializeDebugChunk(response, parentChunk); if ( __DEV__ && - ((debugChunk: any): SomeChunk).status === BLOCKED && + (debugChunk as any as SomeChunk).status === BLOCKED && (response._debugChannel === undefined || !response._debugChannel.hasReadable) ) { @@ -4167,7 +4167,7 @@ const replayConsoleWithCallStack = { const prevStack = ReactSharedInternals.getCurrentStack; ReactSharedInternals.getCurrentStack = getCurrentStackInDEV; currentOwnerInDEV = - owner === null ? (response._debugRootOwner: any) : owner; + owner === null ? (response._debugRootOwner as any) : owner; try { const callStack = buildFakeCallStack( @@ -4205,8 +4205,8 @@ const replayConsoleWithCallStackInDEV: ( ? // We use this technique to trick minifiers to preserve the function name. (replayConsoleWithCallStack.react_stack_bottom_frame.bind( replayConsoleWithCallStack, - ): any) - : (null: any); + ) as any) + : (null as any); type ConsoleEntry = [ string, @@ -4290,7 +4290,7 @@ function initializeIOInfo(response: Response, ioInfo: ReactIOInfo): void { const env = response._rootEnvironmentName; const promise = ioInfo.value; if (promise) { - const thenable: Thenable = (promise: any); + const thenable: Thenable = promise as any; switch (thenable.status) { case INITIALIZED: logIOInfo(ioInfo, env, thenable.value); @@ -4621,7 +4621,7 @@ function flushComponentPerformance( const env = response._rootEnvironmentName; const promise = asyncInfo.awaited.value; if (promise) { - const thenable: Thenable = (promise: any); + const thenable: Thenable = promise as any; switch (thenable.status) { case INITIALIZED: logComponentAwait( @@ -4889,7 +4889,7 @@ function processFullStringRow( return; } case 72 /* "H" */: { - const code: HintCode = (row[0]: any); + const code: HintCode = row[0] as any; resolveHint(response, code, row.slice(1)); return; } @@ -5323,7 +5323,7 @@ function reviveModel( } if (isArray(value)) { for (let i = 0; i < value.length; i++) { - (value: any)[i] = reviveModel(response, value[i], value, '' + i); + (value as any)[i] = reviveModel(response, value[i], value, '' + i); } // $FlowFixMe[invalid-compare] if (value[0] === REACT_ELEMENT_TYPE) { @@ -5335,13 +5335,13 @@ function reviveModel( // Plain object for (const k in value) { if (k === __PROTO__) { - delete (value: any)[k]; + delete (value as any)[k]; } else { - const walked = reviveModel(response, (value: any)[k], value, k); + const walked = reviveModel(response, (value as any)[k], value, k); if (walked !== undefined) { - (value: any)[k] = walked; + (value as any)[k] = walked; } else { - delete (value: any)[k]; + delete (value as any)[k]; } } } @@ -5366,7 +5366,7 @@ export function close(weakResponse: WeakResponse): void { // Clear listeners to release closures and transition to HALTED. // Future .then() calls on HALTED chunks are no-ops. releasePendingChunk(response, chunk); - const haltedChunk: HaltedChunk = (chunk: any); + const haltedChunk: HaltedChunk = chunk as any; haltedChunk.status = HALTED; haltedChunk.value = null; haltedChunk.reason = null; diff --git a/packages/react-client/src/ReactFlightReplyClient.js b/packages/react-client/src/ReactFlightReplyClient.js index 150144c01065..0a4b0edce8e4 100644 --- a/packages/react-client/src/ReactFlightReplyClient.js +++ b/packages/react-client/src/ReactFlightReplyClient.js @@ -415,7 +415,7 @@ export function processReply( } if (typeof value === 'object') { - switch ((value: any).$$typeof) { + switch ((value as any).$$typeof) { case REACT_ELEMENT_TYPE: { if (temporaryReferences !== undefined && key.indexOf(':') === -1) { // TODO: If the property name contains a colon, we don't dedupe. Escape instead. @@ -445,7 +445,7 @@ export function processReply( } case REACT_LAZY_TYPE: { // Resolve lazy as if it wasn't here. In the future this will be encoded as a Promise. - const lazy: LazyComponent = (value: any); + const lazy: LazyComponent = value as any; const payload = lazy._payload; const init = lazy._init; if (formData === null) { @@ -472,7 +472,7 @@ export function processReply( // Suspended pendingParts++; const lazyId = nextPartId++; - const thenable: Thenable = (x: any); + const thenable: Thenable = x as any; const retry = function () { // While the first promise resolved, its value isn't necessarily what we'll // resolve into because we might suspend again. @@ -529,7 +529,7 @@ export function processReply( const promiseId = nextPartId++; const promiseReference = serializePromiseID(promiseId); writtenObjects.set(value, promiseReference); - const thenable: Thenable = (value: any); + const thenable: Thenable = value as any; thenable.then( partValue => { try { @@ -702,7 +702,7 @@ export function processReply( // Iterator, not Iterable const iteratorId = nextPartId++; const partJSON = serializeModel( - Array.from((iterator: any)), + Array.from(iterator as any), iteratorId, ); if (formData === null) { @@ -711,7 +711,7 @@ export function processReply( formData.append(formFieldPrefix + iteratorId, partJSON); return serializeIteratorID(iteratorId); } - return Array.from((iterator: any)); + return Array.from(iterator as any); } // TODO: ReadableStream is not available in old Node. Remove the typeof check later. @@ -721,13 +721,14 @@ export function processReply( ) { return serializeReadableStream(value); } - const getAsyncIterator: void | (() => $AsyncIterator) = - (value: any)[ASYNC_ITERATOR]; + const getAsyncIterator: void | (() => $AsyncIterator) = ( + value as any + )[ASYNC_ITERATOR]; if (typeof getAsyncIterator === 'function') { // We treat AsyncIterables as a Fragment and as such we might need to key them. return serializeAsyncIterable( - (value: any), - getAsyncIterator.call((value: any)), + value as any, + getAsyncIterator.call(value as any), ); } @@ -749,7 +750,7 @@ export function processReply( return serializeTemporaryReferenceMarker(); } if (__DEV__) { - if ((value: any).$$typeof === REACT_CONTEXT_TYPE) { + if ((value as any).$$typeof === REACT_CONTEXT_TYPE) { console.error( 'React Context Providers cannot be passed to Server Functions from the Client.%s', describeObjectForErrorMessage(parent, key), @@ -945,13 +946,13 @@ function encodeFormData(reference: any): Thenable { data.append('0', body); body = data; } - const fulfilled: FulfilledThenable = (thenable: any); + const fulfilled: FulfilledThenable = thenable as any; fulfilled.status = 'fulfilled'; fulfilled.value = body; resolve(body); }, e => { - const rejected: RejectedThenable = (thenable: any); + const rejected: RejectedThenable = thenable as any; rejected.status = 'rejected'; rejected.reason = e; reject(e); @@ -1023,7 +1024,7 @@ function customEncodeFormAction( 'This is a bug in React.', ); } - let boundPromise: Promise> = (referenceClosure.bound: any); + let boundPromise: Promise> = referenceClosure.bound as any; // $FlowFixMe[invalid-compare] if (boundPromise === null) { boundPromise = Promise.resolve([]); @@ -1072,18 +1073,18 @@ function isSignatureEqual( // Only instrument the thenable if the status if not defined. } else { const pendingThenable: PendingThenable> = - (boundPromise: any); + boundPromise as any; pendingThenable.status = 'pending'; pendingThenable.then( (boundArgs: Array) => { const fulfilledThenable: FulfilledThenable> = - (boundPromise: any); + boundPromise as any; fulfilledThenable.status = 'fulfilled'; fulfilledThenable.value = boundArgs; }, (error: mixed) => { const rejectedThenable: RejectedThenable = - (boundPromise: any); + boundPromise as any; rejectedThenable.status = 'rejected'; rejectedThenable.reason = error; }, @@ -1220,7 +1221,7 @@ export function registerBoundServerReference( encodeFormAction, ); }; - Object.defineProperties((reference: any), { + Object.defineProperties(reference as any, { $$FORM_ACTION: {value: $$FORM_ACTION}, $$IS_SIGNATURE_EQUAL: {value: isSignatureEqual}, bind: {value: bind}, @@ -1266,7 +1267,7 @@ function bind(this: Function): Function { const args = ArraySlice.call(arguments, 1); let boundPromise = null; if (referenceClosure.bound !== null) { - boundPromise = Promise.resolve((referenceClosure.bound: any)).then( + boundPromise = Promise.resolve(referenceClosure.bound as any).then( boundArgs => boundArgs.concat(args), ); } else { @@ -1284,7 +1285,7 @@ function bind(this: Function): Function { // $FlowFixMe[constant-condition] if (usedWithSSR) { // Only expose this in builds that would actually use it. Not needed on the client. - Object.defineProperties((newFn: any), { + Object.defineProperties(newFn as any, { $$FORM_ACTION: {value: this.$$FORM_ACTION}, $$IS_SIGNATURE_EQUAL: {value: isSignatureEqual}, bind: {value: bind}, @@ -1326,7 +1327,7 @@ export function createBoundServerReference, T>( } // Since this is a fake Promise whose .then doesn't chain, we have to wrap it. // TODO: Remove the wrapper once that's fixed. - return ((Promise.resolve(p): any): Promise>).then( + return (Promise.resolve(p) as any as Promise>).then( function (boundArgs) { return callServer(id, boundArgs.concat(args)); }, diff --git a/packages/react-client/src/ReactFlightTemporaryReferences.js b/packages/react-client/src/ReactFlightTemporaryReferences.js index 5ad92b3a1063..c259942f9aa0 100644 --- a/packages/react-client/src/ReactFlightTemporaryReferences.js +++ b/packages/react-client/src/ReactFlightTemporaryReferences.js @@ -27,5 +27,5 @@ export function readTemporaryReference( set: TemporaryReferenceSet, reference: string, ): T { - return (set.get(reference): any); + return set.get(reference) as any; } diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js index c288b7851f58..585205e02c6e 100644 --- a/packages/react-debug-tools/src/ReactDebugHooks.js +++ b/packages/react-debug-tools/src/ReactDebugHooks.js @@ -74,7 +74,7 @@ function getPrimitiveStackCache(): Map> { let readHookLog; try { // Use all hooks here to add them to the hook log. - Dispatcher.useContext(({_currentValue: null}: any)); + Dispatcher.useContext({_currentValue: null} as any); Dispatcher.useState(null); Dispatcher.useReducer((s: mixed, a: mixed) => s, null); Dispatcher.useRef(null); @@ -106,23 +106,19 @@ function getPrimitiveStackCache(): Map> { } if (typeof Dispatcher.use === 'function') { // This type check is for Flow only. - Dispatcher.use( - ({ - $$typeof: REACT_CONTEXT_TYPE, - _currentValue: null, - }: any), - ); + Dispatcher.use({ + $$typeof: REACT_CONTEXT_TYPE, + _currentValue: null, + } as any); Dispatcher.use({ then() {}, status: 'fulfilled', value: null, }); try { - Dispatcher.use( - ({ - then() {}, - }: any), - ); + Dispatcher.use({ + then() {}, + } as any); } catch (x) {} } @@ -174,7 +170,7 @@ function readContext(context: ReactContext): T { // For now we don't expose readContext usage in the hooks debugging info. if (hasOwnProperty.call(currentContextDependency, 'memoizedValue')) { // $FlowFixMe[incompatible-use] Flow thinks `hasOwnProperty` mutates `currentContextDependency` - value = ((currentContextDependency.memoizedValue: any): T); + value = currentContextDependency.memoizedValue as any as T; // $FlowFixMe[incompatible-use] Flow thinks `hasOwnProperty` mutates `currentContextDependency` currentContextDependency = currentContextDependency.next; @@ -211,7 +207,7 @@ function use(usable: Usable): T { currentThenableState !== null && currentThenableIndex < currentThenableState.length ? currentThenableState[currentThenableIndex++] - : (usable: any); + : (usable as any); switch (thenable.status) { case 'fulfilled': { @@ -245,7 +241,7 @@ function use(usable: Usable): T { }); throw SuspenseException; } else if (usable.$$typeof === REACT_CONTEXT_TYPE) { - const context: ReactContext = (usable: any); + const context: ReactContext = usable as any; const value = readContext(context); hookLog.push({ @@ -310,7 +306,7 @@ function useReducer( if (hook !== null) { state = hook.memoizedState; } else { - state = init !== undefined ? init(initialArg) : ((initialArg: any): S); + state = init !== undefined ? init(initialArg) : (initialArg as any as S); } hookLog.push({ displayName: null, @@ -608,7 +604,7 @@ function useFormState( // $FlowFixMe[method-unbinding] typeof actionResult.then === 'function' ) { - const thenable: Thenable> = (actionResult: any); + const thenable: Thenable> = actionResult as any; switch (thenable.status) { case 'fulfilled': { value = thenable.value; @@ -630,7 +626,7 @@ function useFormState( value = thenable; } } else { - value = (actionResult: any); + value = actionResult as any; } } else { value = initialState; @@ -651,7 +647,7 @@ function useFormState( // value being a Thenable is equivalent to error being not null // i.e. we only reach this point with Awaited - const state = ((value: any): Awaited); + const state = value as any as Awaited; // TODO: support displaying pending value return [state, (payload: P) => {}, false]; @@ -678,7 +674,7 @@ function useActionState( // $FlowFixMe[method-unbinding] typeof actionResult.then === 'function' ) { - const thenable: Thenable> = (actionResult: any); + const thenable: Thenable> = actionResult as any; switch (thenable.status) { case 'fulfilled': { value = thenable.value; @@ -700,7 +696,7 @@ function useActionState( value = thenable; } } else { - value = (actionResult: any); + value = actionResult as any; } } else { value = initialState; @@ -721,7 +717,7 @@ function useActionState( // value being a Thenable is equivalent to error being not null // i.e. we only reach this point with Awaited - const state = ((value: any): Awaited); + const state = value as any as Awaited; // TODO: support displaying pending value return [state, (payload: P) => {}, false]; @@ -731,10 +727,10 @@ function useHostTransitionStatus(): TransitionStatus { const status = readContext( // $FlowFixMe[prop-missing] `readContext` only needs _currentValue // $FlowFixMe[incompatible-type] - ({ + { // $FlowFixMe[incompatible-type] TODO: Incorrect bottom value without access to Fiber config. _currentValue: null, - }: ReactContext), + } as ReactContext, ); hookLog.push({ @@ -1228,7 +1224,7 @@ export function inspectHooks( } const rootStack = ancestorStackError === undefined - ? ([]: ParsedStackFrame[]) + ? ([] as Array) : ErrorStackParser.parse(ancestorStackError); return buildTree(rootStack, readHookLog); } @@ -1238,9 +1234,9 @@ function setupContexts(contextMap: Map, any>, fiber: Fiber) { while (current) { if (current.tag === ContextProvider) { let context: ReactContext = current.type; - if ((context: any)._context !== undefined) { + if ((context as any)._context !== undefined) { // Support inspection of pre-19+ providers. - context = (context: any)._context; + context = (context as any)._context; } if (!contextMap.has(context)) { // Store the current value that we're going to restore later. @@ -1279,7 +1275,7 @@ function inspectHooksOfForwardRef( } const rootStack = ancestorStackError === undefined - ? ([]: ParsedStackFrame[]) + ? ([] as Array) : ErrorStackParser.parse(ancestorStackError); return buildTree(rootStack, readHookLog); } @@ -1324,7 +1320,7 @@ export function inspectHooksOfFiber( // Set up the current hook so that we can step through and read the // current state from them. - currentHook = (fiber.memoizedState: Hook); + currentHook = fiber.memoizedState as Hook; currentFiber = fiber; const thenableState = fiber.dependencies && fiber.dependencies._debugThenableState; @@ -1341,17 +1337,17 @@ export function inspectHooksOfFiber( currentContextDependency = dependencies !== null ? dependencies.firstContext : null; } else if (hasOwnProperty.call(currentFiber, 'dependencies_old')) { - const dependencies: Dependencies = (currentFiber: any).dependencies_old; + const dependencies: Dependencies = (currentFiber as 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; + const dependencies: Dependencies = (currentFiber as any).dependencies_new; currentContextDependency = // $FlowFixMe[invalid-compare] dependencies !== null ? dependencies.firstContext : null; } else if (hasOwnProperty.call(currentFiber, 'contextDependencies')) { - const contextDependencies = (currentFiber: any).contextDependencies; + const contextDependencies = (currentFiber as any).contextDependencies; currentContextDependency = contextDependencies !== null ? contextDependencies.first : null; } else { diff --git a/packages/react-devtools-core/src/backend.js b/packages/react-devtools-core/src/backend.js index 5e70a178bace..7367e7bd1bc2 100644 --- a/packages/react-devtools-core/src/backend.js +++ b/packages/react-devtools-core/src/backend.js @@ -99,7 +99,7 @@ export function connectToDevTools(options: ?ConnectOptions) { useHttps = false, port = 8097, websocket, - resolveRNStyle = (null: $FlowFixMe), + resolveRNStyle = null as $FlowFixMe, retryConnectionDelay = 2000, isAppActive = () => true, onSettingsUpdated, @@ -217,7 +217,7 @@ export function connectToDevTools(options: ?ConnectOptions) { bridge, agent, // $FlowFixMe[constant-condition] - ((resolveRNStyle || hook.resolveRNStyle: any): ResolveNativeStyle), + (resolveRNStyle || hook.resolveRNStyle) as any as ResolveNativeStyle, nativeStyleEditorValidAttributes || hook.nativeStyleEditorValidAttributes || null, @@ -241,36 +241,28 @@ export function connectToDevTools(options: ?ConnectOptions) { }; if (!hook.hasOwnProperty('resolveRNStyle')) { - Object.defineProperty( - hook, - 'resolveRNStyle', - ({ - enumerable: false, - get() { - return lazyResolveRNStyle; - }, - set(value: $FlowFixMe) { - lazyResolveRNStyle = value; - initAfterTick(); - }, - }: Object), - ); + Object.defineProperty(hook, 'resolveRNStyle', { + enumerable: false, + get() { + return lazyResolveRNStyle; + }, + set(value: $FlowFixMe) { + lazyResolveRNStyle = value; + initAfterTick(); + }, + } as Object); } if (!hook.hasOwnProperty('nativeStyleEditorValidAttributes')) { - Object.defineProperty( - hook, - 'nativeStyleEditorValidAttributes', - ({ - enumerable: false, - get() { - return lazyNativeStyleEditorValidAttributes; - }, - set(value: $FlowFixMe) { - lazyNativeStyleEditorValidAttributes = value; - initAfterTick(); - }, - }: Object), - ); + Object.defineProperty(hook, 'nativeStyleEditorValidAttributes', { + enumerable: false, + get() { + return lazyNativeStyleEditorValidAttributes; + }, + set(value: $FlowFixMe) { + lazyNativeStyleEditorValidAttributes = value; + initAfterTick(); + }, + } as Object); } } }; @@ -311,7 +303,7 @@ export function connectToDevTools(options: ?ConnectOptions) { } } catch (e) { console.error( - '[React DevTools] Failed to parse JSON: ' + (event.data: any), + '[React DevTools] Failed to parse JSON: ' + (event.data as any), ); return; } diff --git a/packages/react-devtools-core/src/standalone.js b/packages/react-devtools-core/src/standalone.js index 6d32f18c4851..3e2538d47750 100644 --- a/packages/react-devtools-core/src/standalone.js +++ b/packages/react-devtools-core/src/standalone.js @@ -32,7 +32,7 @@ export type StatusTypes = 'server-connected' | 'devtools-connected' | 'error'; export type StatusListener = (message: string, status: StatusTypes) => void; export type OnDisconnectedCallback = () => void; -let node: HTMLElement = ((null: any): HTMLElement); +let node: HTMLElement = null as any as HTMLElement; let nodeWaitingToConnectHTML: string = ''; let projectRoots: Array = []; let statusListener: StatusListener = ( @@ -112,11 +112,11 @@ function reload() { root = createRoot(node); root.render( createElement(DevTools, { - bridge: ((bridge: any): FrontendBridge), + bridge: bridge as any as FrontendBridge, canViewElementSourceFunction, hookNamesModuleLoaderFunction, showTabBar: true, - store: ((store: any): Store), + store: store as any as Store, warnIfLegacyBackendDetected: true, viewElementSourceFunction, fetchFileWithCaching, @@ -263,7 +263,7 @@ function initialize(socket: WebSocket) { } }, }); - ((bridge: any): FrontendBridge).addListener('shutdown', () => { + (bridge as any as FrontendBridge).addListener('shutdown', () => { socket.close(); }); diff --git a/packages/react-devtools-extensions/src/main/index.js b/packages/react-devtools-extensions/src/main/index.js index 5954460edb68..1edbbf5e1cd3 100644 --- a/packages/react-devtools-extensions/src/main/index.js +++ b/packages/react-devtools-extensions/src/main/index.js @@ -486,10 +486,10 @@ function performInTabNavigationCleanup() { // Do not clean mostRecentOverrideTab on purpose, so we remember last opened // React DevTools tab, when user does in-tab navigation - store = (null: $FlowFixMe); - bridge = (null: $FlowFixMe); - render = (null: $FlowFixMe); - root = (null: $FlowFixMe); + store = null as $FlowFixMe; + bridge = null as $FlowFixMe; + render = null as $FlowFixMe; + root = null as $FlowFixMe; } function performFullCleanup() { @@ -511,15 +511,15 @@ function performFullCleanup() { componentsPortalContainer = null; profilerPortalContainer = null; suspensePortalContainer = null; - root = (null: $FlowFixMe); + root = null as $FlowFixMe; mostRecentOverrideTab = null; - store = (null: $FlowFixMe); - bridge = (null: $FlowFixMe); - render = (null: $FlowFixMe); + store = null as $FlowFixMe; + bridge = null as $FlowFixMe; + render = null as $FlowFixMe; port?.disconnect(); - port = (null: $FlowFixMe); + port = null as $FlowFixMe; } function connectExtensionPort(): void { @@ -546,7 +546,7 @@ function connectExtensionPort(): void { // so, when we call `port.disconnect()` from this script, // this should not trigger this callback and port reconnection port.onDisconnect.addListener(() => { - port = (null: $FlowFixMe); + port = null as $FlowFixMe; connectExtensionPort(); }); } @@ -599,9 +599,9 @@ function mountReactDevToolsWhenReactHasLoaded() { ); } -let bridge: FrontendBridge = (null: $FlowFixMe); +let bridge: FrontendBridge = null as $FlowFixMe; let lastSubscribedBridgeListener = null; -let store: Store = (null: $FlowFixMe); +let store: Store = null as $FlowFixMe; let profilingData = null; @@ -617,12 +617,12 @@ let editorPortalContainer = null; let inspectedElementPortalContainer = null; let mostRecentOverrideTab: null | TabID = null; -let render: (overrideTab?: TabID) => void = (null: $FlowFixMe); -let root: RootType = (null: $FlowFixMe); +let render: (overrideTab?: TabID) => void = null as $FlowFixMe; +let root: RootType = null as $FlowFixMe; let currentSelectedSource: null | SourceSelection = null; -let port: ExtensionRuntimePort = (null: $FlowFixMe); +let port: ExtensionRuntimePort = null as $FlowFixMe; // In case when multiple navigation events emitted in a short period of time // This debounced callback primarily used to avoid mounting React DevTools multiple times, which results diff --git a/packages/react-devtools-inline/src/backend.js b/packages/react-devtools-inline/src/backend.js index 9810d5b39ccf..8b0ab3584325 100644 --- a/packages/react-devtools-inline/src/backend.js +++ b/packages/react-devtools-inline/src/backend.js @@ -109,7 +109,7 @@ export function createBridge(contentWindow: any, wall?: Wall): BackendBridge { }; } - return (new Bridge(wall): BackendBridge); + return new Bridge(wall) as BackendBridge; } export function initialize(contentWindow: any): void { diff --git a/packages/react-devtools-inline/src/frontend.js b/packages/react-devtools-inline/src/frontend.js index b8d1b2ef4d81..28fe70b1b299 100644 --- a/packages/react-devtools-inline/src/frontend.js +++ b/packages/react-devtools-inline/src/frontend.js @@ -40,7 +40,7 @@ export function createBridge(contentWindow: any, wall?: Wall): FrontendBridge { }; } - return (new Bridge(wall): FrontendBridge); + return new Bridge(wall) as FrontendBridge; } export function initialize( @@ -58,7 +58,7 @@ export function initialize( } // Type refinement. - const frontendBridge = ((bridge: any): FrontendBridge); + const frontendBridge = bridge as any as FrontendBridge; if (store == null) { store = createStore(frontendBridge); diff --git a/packages/react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor.js b/packages/react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor.js index 7a8bfff43bf2..8b9db86fcc7a 100644 --- a/packages/react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor.js +++ b/packages/react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor.js @@ -97,14 +97,11 @@ function measureStyle( ) { const data = agent.getInstanceAndStyle({id, rendererID}); if (!data || !data.style) { - bridge.send( - 'NativeStyleEditor_styleAndLayout', - ({ - id, - layout: null, - style: null, - }: StyleAndLayout), - ); + bridge.send('NativeStyleEditor_styleAndLayout', { + id, + layout: null, + style: null, + } as StyleAndLayout); return; } @@ -119,14 +116,11 @@ function measureStyle( } if (!instance || typeof instance.measure !== 'function') { - bridge.send( - 'NativeStyleEditor_styleAndLayout', - ({ - id, - layout: null, - style: resolvedStyle || null, - }: StyleAndLayout), - ); + bridge.send('NativeStyleEditor_styleAndLayout', { + id, + layout: null, + style: resolvedStyle || null, + } as StyleAndLayout); return; } @@ -134,14 +128,11 @@ function measureStyle( // RN Android sometimes returns undefined here. Don't send measurements in this case. // https://github.com/jhen0409/react-native-debugger/issues/84#issuecomment-304611817 if (typeof x !== 'number') { - bridge.send( - 'NativeStyleEditor_styleAndLayout', - ({ - id, - layout: null, - style: resolvedStyle || null, - }: StyleAndLayout), - ); + bridge.send('NativeStyleEditor_styleAndLayout', { + id, + layout: null, + style: resolvedStyle || null, + } as StyleAndLayout); return; } const margin = @@ -150,23 +141,20 @@ function measureStyle( const padding = (resolvedStyle != null && resolveBoxStyle('padding', resolvedStyle)) || EMPTY_BOX_STYLE; - bridge.send( - 'NativeStyleEditor_styleAndLayout', - ({ - id, - layout: { - x, - y, - width, - height, - left, - top, - margin, - padding, - }, - style: resolvedStyle || null, - }: StyleAndLayout), - ); + bridge.send('NativeStyleEditor_styleAndLayout', { + id, + layout: { + x, + y, + width, + height, + left, + top, + margin, + padding, + }, + style: resolvedStyle || null, + } as StyleAndLayout); }); } @@ -194,7 +182,7 @@ function renameStyle( const {instance, style} = data; const newStyle = newName - ? {[oldName]: (undefined: string | void), [newName]: value} + ? {[oldName]: undefined as string | void, [newName]: value} : {[oldName]: undefined}; let customStyle; diff --git a/packages/react-devtools-shared/src/backend/StyleX/utils.js b/packages/react-devtools-shared/src/backend/StyleX/utils.js index ad137c7184e5..1c7769c51d6c 100644 --- a/packages/react-devtools-shared/src/backend/StyleX/utils.js +++ b/packages/react-devtools-shared/src/backend/StyleX/utils.js @@ -82,7 +82,7 @@ function crawlObjectProperties( function getPropertyValueForStyleName(styleName: string): string | null { if (cachedStyleNameToValueMap.has(styleName)) { - return ((cachedStyleNameToValueMap.get(styleName): any): string); + return cachedStyleNameToValueMap.get(styleName) as any as string; } for ( @@ -90,9 +90,9 @@ function getPropertyValueForStyleName(styleName: string): string | null { styleSheetIndex < document.styleSheets.length; styleSheetIndex++ ) { - const styleSheet = ((document.styleSheets[ + const styleSheet = document.styleSheets[ styleSheetIndex - ]: any): CSSStyleSheet); + ] as any as CSSStyleSheet; let rules: CSSRuleList | null = null; // this might throw if CORS rules are enforced https://www.w3.org/TR/cssom-1/#the-cssstylesheet-interface try { @@ -105,7 +105,7 @@ function getPropertyValueForStyleName(styleName: string): string | null { if (!(rules[ruleIndex] instanceof CSSStyleRule)) { continue; } - const rule = ((rules[ruleIndex]: any): CSSStyleRule); + const rule = rules[ruleIndex] as any as CSSStyleRule; const {cssText, selectorText, style} = rule; if (selectorText != null) { diff --git a/packages/react-devtools-shared/src/backend/agent.js b/packages/react-devtools-shared/src/backend/agent.js index 73fb202ad4e0..be566b4c4d35 100644 --- a/packages/react-devtools-shared/src/backend/agent.js +++ b/packages/react-devtools-shared/src/backend/agent.js @@ -226,9 +226,9 @@ function mergeRoots( } const leftSuspendedBy: DehydratedData = left.suspendedBy; - const {data, cleaned, unserializable} = (right.suspendedBy: DehydratedData); - const leftSuspendedByData = ((leftSuspendedBy.data: any): Array); - const rightSuspendedByData = ((data: any): Array); + const {data, cleaned, unserializable} = right.suspendedBy as DehydratedData; + const leftSuspendedByData = leftSuspendedBy.data as any as Array; + const rightSuspendedByData = data as any as Array; for (let i = 0; i < rightSuspendedByData.length; i++) { leftSuspendedByData.push(rightSuspendedByData[i]); } @@ -464,9 +464,9 @@ export default class Agent extends EventEmitter<{ if (isReactNativeEnvironment() || typeof target.nodeType !== 'number') { // In React Native or non-DOM we simply pick any renderer that has a match. for (const rendererID in this._rendererInterfaces) { - const renderer = ((this._rendererInterfaces[ - (rendererID: any) - ]: any): RendererInterface); + const renderer = this._rendererInterfaces[ + rendererID as any + ] as any as RendererInterface; try { const id = onlySuspenseNodes ? renderer.getSuspenseNodeIDForHostInstance(target) @@ -491,11 +491,11 @@ export default class Agent extends EventEmitter<{ let bestRendererID: number = 0; // Find the nearest ancestor which is mounted by a React. for (const rendererID in this._rendererInterfaces) { - const renderer = ((this._rendererInterfaces[ - (rendererID: any) - ]: any): RendererInterface); + const renderer = this._rendererInterfaces[ + rendererID as any + ] as any as RendererInterface; const nearestNode: null | Element = renderer.getNearestMountedDOMNode( - (target: any), + target as any, ); if (nearestNode !== null) { if (nearestNode === target) { @@ -537,9 +537,9 @@ export default class Agent extends EventEmitter<{ getComponentNameForHostInstance(target: HostInstance): string | null { const match = this.getIDForHostInstance(target); if (match !== null) { - const renderer = ((this._rendererInterfaces[ - (match.rendererID: any) - ]: any): RendererInterface); + const renderer = this._rendererInterfaces[ + match.rendererID as any + ] as any as RendererInterface; return renderer.getDisplayNameForElementID(match.id); } return null; @@ -575,7 +575,7 @@ export default class Agent extends EventEmitter<{ console.warn(`Invalid renderer id "${rendererID}" for element "${id}"`); } else { const owners = renderer.getOwnersList(id); - this._bridge.send('ownersList', ({id, owners}: OwnersList)); + this._bridge.send('ownersList', {id, owners} as OwnersList); } }; @@ -653,9 +653,9 @@ export default class Agent extends EventEmitter<{ } for (const rendererID in this._rendererInterfaces) { - const renderer = ((this._rendererInterfaces[ - (rendererID: any) - ]: any): RendererInterface); + const renderer = this._rendererInterfaces[ + rendererID as any + ] as any as RendererInterface; let path: InspectElementParams['path'] = null; if (suspendedByPathIndex !== null && rendererPath !== null) { const suspendedByPathRendererIndex = @@ -709,14 +709,14 @@ export default class Agent extends EventEmitter<{ mergeRoots(inspectedScreen, inspectedRoots, suspendedByOffset); const dehydratedSuspendedBy: DehydratedData = inspectedRoots.suspendedBy; - const suspendedBy = ((dehydratedSuspendedBy.data: any): Array); + const suspendedBy = dehydratedSuspendedBy.data as any as Array; suspendedByOffset += suspendedBy.length; found = true; break; case 'no-change': found = true; const rootsSuspendedBy: Array = - (renderer.getElementAttributeByPath(id, ['suspendedBy']): any); + renderer.getElementAttributeByPath(id, ['suspendedBy']) as any; suspendedByOffset += rootsSuspendedBy.length; break; case 'not-found': @@ -792,9 +792,9 @@ export default class Agent extends EventEmitter<{ rendererID, suspendedSet, }) => { - const renderer = ((this._rendererInterfaces[ - (rendererID: any) - ]: any): RendererInterface); + const renderer = this._rendererInterfaces[ + rendererID as any + ] as any as RendererInterface; if (renderer.supportsTogglingSuspense) { renderer.overrideSuspenseMilestone(suspendedSet); } @@ -978,9 +978,9 @@ export default class Agent extends EventEmitter<{ setTraceUpdatesEnabled(traceUpdatesEnabled); for (const rendererID in this._rendererInterfaces) { - const renderer = ((this._rendererInterfaces[ - (rendererID: any) - ]: any): RendererInterface); + const renderer = this._rendererInterfaces[ + rendererID as any + ] as any as RendererInterface; renderer.setTraceUpdatesEnabled(traceUpdatesEnabled); } }; @@ -1004,9 +1004,9 @@ export default class Agent extends EventEmitter<{ }) => void = ({recordChangeDescriptions, recordTimeline}) => { this._isProfiling = true; for (const rendererID in this._rendererInterfaces) { - const renderer = ((this._rendererInterfaces[ - (rendererID: any) - ]: any): RendererInterface); + const renderer = this._rendererInterfaces[ + rendererID as any + ] as any as RendererInterface; renderer.startProfiling(recordChangeDescriptions, recordTimeline); } this._bridge.send('profilingStatus', this._isProfiling); @@ -1015,9 +1015,9 @@ export default class Agent extends EventEmitter<{ stopProfiling: () => void = () => { this._isProfiling = false; for (const rendererID in this._rendererInterfaces) { - const renderer = ((this._rendererInterfaces[ - (rendererID: any) - ]: any): RendererInterface); + const renderer = this._rendererInterfaces[ + rendererID as any + ] as any as RendererInterface; renderer.stopProfiling(); } this._bridge.send('profilingStatus', this._isProfiling); @@ -1060,9 +1060,9 @@ export default class Agent extends EventEmitter<{ componentFilters => { for (const rendererIDString in this._rendererInterfaces) { const rendererID = +rendererIDString; - const renderer = ((this._rendererInterfaces[ - (rendererID: any) - ]: any): RendererInterface); + const renderer = this._rendererInterfaces[ + rendererID as any + ] as any as RendererInterface; if (this._lastSelectedRendererID === rendererID) { // Changing component filters will unmount and remount the DevTools tree. // Track the last selection's path so we can restore the selection. @@ -1204,7 +1204,7 @@ export default class Agent extends EventEmitter<{ if (path !== null) { sessionStorageSetItem( SESSION_STORAGE_LAST_SELECTION_KEY, - JSON.stringify(({rendererID, path}: PersistedSelection)), + JSON.stringify({rendererID, path} as PersistedSelection), ); } else { sessionStorageRemoveItem(SESSION_STORAGE_LAST_SELECTION_KEY); diff --git a/packages/react-devtools-shared/src/backend/fiber/DevToolsFiberComponentStack.js b/packages/react-devtools-shared/src/backend/fiber/DevToolsFiberComponentStack.js index c938b6736323..4481b7865eed 100644 --- a/packages/react-devtools-shared/src/backend/fiber/DevToolsFiberComponentStack.js +++ b/packages/react-devtools-shared/src/backend/fiber/DevToolsFiberComponentStack.js @@ -165,7 +165,7 @@ export function getOwnerStackByFiberInDev( if (workInProgress.tag === HostText) { // Text nodes never have an owner/stack because they're not created through JSX. // We use the parent since text nodes are always created through a host parent. - workInProgress = (workInProgress.return: any); + workInProgress = workInProgress.return as any; } // The owner stack of the current fiber will be where it was created, i.e. inside its owner. @@ -197,7 +197,7 @@ export function getOwnerStackByFiberInDev( while (owner) { if (typeof owner.tag === 'number') { - const fiber: Fiber = (owner: any); + const fiber: Fiber = owner as any; owner = fiber._debugOwner; let debugStack: void | null | string | Error = fiber._debugStack; // If we don't actually print the stack if there is no owner of this JSX element. diff --git a/packages/react-devtools-shared/src/backend/fiber/renderer.js b/packages/react-devtools-shared/src/backend/fiber/renderer.js index bbc38d341a29..77adb8b4f564 100644 --- a/packages/react-devtools-shared/src/backend/fiber/renderer.js +++ b/packages/react-devtools-shared/src/backend/fiber/renderer.js @@ -215,7 +215,7 @@ function createFiberInstance(fiber: Fiber): FiberInstance { // This is used to represent a filtered Fiber but still lets us find its host instance. function createFilteredFiberInstance(fiber: Fiber): FilteredFiberInstance { - return ({ + return { kind: FILTERED_FIBER_INSTANCE, id: 0, parent: null, @@ -227,7 +227,7 @@ function createFilteredFiberInstance(fiber: Fiber): FilteredFiberInstance { suspendedBy: null, suspenseNode: null, data: fiber, - }: any); + } as any; } function createVirtualInstance( @@ -290,14 +290,14 @@ export function getDispatcherRef(renderer: { // We got a legacy dispatcher injected, let's create a wrapper proxy to translate. return { get H() { - return (injectedRef: any).current; + return (injectedRef as any).current; }, set H(value) { - (injectedRef: any).current = value; + (injectedRef as any).current = value; }, }; } - return (injectedRef: any); + return injectedRef as any; } // All environment names we've seen so far. This lets us create a list of filters to apply. @@ -971,7 +971,7 @@ export function attach( currentRoot = rootInstance; unmountInstanceRecursively(rootInstance); rootToFiberInstanceMap.delete(root); - currentRoot = (null: any); + currentRoot = null as any; }); if ( @@ -1040,7 +1040,7 @@ export function attach( currentRoot = newRoot; setRootPseudoKey(currentRoot.id, root.current); mountFiberRecursively(root.current, false); - currentRoot = (null: any); + currentRoot = null as any; }); // We need to write back the new ID for the focused Fiber. @@ -1278,7 +1278,7 @@ export function attach( } // When a mount or update is in progress, this value tracks the root that is being operated on. - let currentRoot: FiberInstance = (null: any); + let currentRoot: FiberInstance = null as any; // Removes a Fiber (and its alternate) from the Maps used to track their id. // This method should always be called when a Fiber is unmounting. @@ -2884,7 +2884,7 @@ export function attach( for (let i = 0; i < debugInfo.length; i++) { const debugEntry = debugInfo[i]; if (debugEntry.awaited) { - const asyncInfo: ReactAsyncInfo = (debugEntry: any); + const asyncInfo: ReactAsyncInfo = debugEntry as any; insertSuspendedBy(asyncInfo); } } @@ -2917,7 +2917,7 @@ export function attach( for (let j = 0; j < debugInfo.length; j++) { const debugEntry = debugInfo[j]; if (debugEntry.awaited) { - const asyncInfo: ReactAsyncInfo = (debugEntry: any); + const asyncInfo: ReactAsyncInfo = debugEntry as any; insertSuspendedBy(asyncInfo); } } @@ -2989,14 +2989,14 @@ export function attach( start = resourceEntry.startTime; end = start + resourceEntry.duration; // $FlowFixMe[prop-missing] - byteSize = (resourceEntry.transferSize: any) || 0; + byteSize = (resourceEntry.transferSize as any) || 0; } } } const value = instance.sheet; const promise = Promise.resolve(value); - (promise: any).status = 'fulfilled'; - (promise: any).value = value; + (promise as any).status = 'fulfilled'; + (promise as any).value = value; const ioInfo: ReactIOInfo = { name: 'stylesheet', start, @@ -3085,9 +3085,9 @@ export function attach( start = resourceEntry.startTime; end = start + resourceEntry.duration; // $FlowFixMe[prop-missing] - fileSize = (resourceEntry.decodedBodySize: any) || 0; + fileSize = (resourceEntry.decodedBodySize as any) || 0; // $FlowFixMe[prop-missing] - byteSize = (resourceEntry.transferSize: any) || 0; + byteSize = (resourceEntry.transferSize as any) || 0; } } } @@ -3111,8 +3111,8 @@ export function attach( value.fileSize = fileSize; } const promise = Promise.resolve(value); - (promise: any).status = 'fulfilled'; - (promise: any).value = value; + (promise as any).status = 'fulfilled'; + (promise as any).value = value; const ioInfo: ReactIOInfo = { name: 'img', start, @@ -3175,7 +3175,7 @@ export function attach( const debugEntry = fiber._debugInfo[i]; if (debugEntry.awaited) { // Async Info - const asyncInfo: ReactAsyncInfo = (debugEntry: any); + const asyncInfo: ReactAsyncInfo = debugEntry as any; if (level === virtualLevel) { // Track any async info between the previous virtual instance up until to this // instance and add it to the parent. This can add the same set multiple times @@ -3189,7 +3189,7 @@ export function attach( continue; } // Scan up until the next Component to see if this component changed environment. - const componentInfo: ReactComponentInfo = (debugEntry: any); + const componentInfo: ReactComponentInfo = debugEntry as any; const secondaryEnv = getSecondaryEnvironmentName(fiber._debugInfo, i); if (componentInfo.env != null) { knownEnvironmentNames.add(componentInfo.env); @@ -3789,7 +3789,7 @@ export function attach( // In some cases actualDuration might be 0 for fibers we worked on (particularly if we're using Date.now) // In other cases (e.g. Memo) actualDuration might be greater than 0 even if we "bailed out". const metadata = - ((currentCommitProfilingMetadata: any): CommitProfilingData); + currentCommitProfilingMetadata as any as CommitProfilingData; metadata.durations.push(id, actualDuration, selfDuration); metadata.maxActualDuration = Math.max( metadata.maxActualDuration, @@ -3819,7 +3819,7 @@ export function attach( (fiber.alternate !== null && updaters.has(fiber.alternate))) ) { const metadata = - ((currentCommitProfilingMetadata: any): CommitProfilingData); + currentCommitProfilingMetadata as any as CommitProfilingData; if (metadata.updaters === null) { metadata.updaters = []; } @@ -4044,7 +4044,7 @@ export function attach( const debugEntry = nextChild._debugInfo[i]; if (debugEntry.awaited) { // Async Info - const asyncInfo: ReactAsyncInfo = (debugEntry: any); + const asyncInfo: ReactAsyncInfo = debugEntry as any; if (level === virtualLevel) { // Track any async info between the previous virtual instance up until to this // instance and add it to the parent. This can add the same set multiple times @@ -4057,7 +4057,7 @@ export function attach( // Not a Component. Some other Debug Info. continue; } - const componentInfo: ReactComponentInfo = (debugEntry: any); + const componentInfo: ReactComponentInfo = debugEntry as any; const secondaryEnv = getSecondaryEnvironmentName( nextChild._debugInfo, i, @@ -4218,7 +4218,7 @@ export function attach( if (existingInstance !== null) { // Common case. Match in the same parent. const fiberInstance: FiberInstance | FilteredFiberInstance = - (existingInstance: any); // Only matches if it's a Fiber. + existingInstance as any; // Only matches if it's a Fiber. // We keep track if the order of the children matches the previous order. // They are always different referentially, but if the instances line up @@ -4235,7 +4235,7 @@ export function attach( updateFlags |= updateFiberRecursively( fiberInstance, nextChild, - (prevChild: any), + prevChild as any, traceNearestHostComponentUpdate, ); } else if (prevChild !== null && shouldFilterFiber(nextChild)) { @@ -5054,7 +5054,7 @@ export function attach( flushPendingEvents(currentRoot); - currentRoot = (null: any); + currentRoot = null as any; }); needsToFlushComponentLogs = false; @@ -5169,20 +5169,20 @@ export function attach( if (isProfiling && isProfilingSupported) { if (!shouldBailoutWithPendingOperations()) { - const commitProfilingMetadata = - ((rootToCommitProfilingMetadataMap: any): CommitProfilingMetadataMap).get( - currentRoot.id, - ); + const commitProfilingMetadata = ( + rootToCommitProfilingMetadataMap as any as CommitProfilingMetadataMap + ).get(currentRoot.id); if (commitProfilingMetadata != null) { commitProfilingMetadata.push( - ((currentCommitProfilingMetadata: any): CommitProfilingData), + currentCommitProfilingMetadata as any as CommitProfilingData, ); } else { - ((rootToCommitProfilingMetadataMap: any): CommitProfilingMetadataMap).set( - currentRoot.id, - [((currentCommitProfilingMetadata: any): CommitProfilingData)], - ); + ( + rootToCommitProfilingMetadataMap as any as CommitProfilingMetadataMap + ).set(currentRoot.id, [ + currentCommitProfilingMetadata as any as CommitProfilingData, + ]); } } } @@ -5196,7 +5196,7 @@ export function attach( hook.emit('traceUpdates', traceUpdatesForNodes); } - currentRoot = (null: any); + currentRoot = null as any; } function getResourceInstance(fiber: Fiber): HostInstance | null { @@ -5331,7 +5331,7 @@ export function attach( const owner = getUnfilteredOwner(fiber); if (owner != null) { if (typeof owner.tag === 'number') { - return getDisplayNameForFiber((owner: any)); + return getDisplayNameForFiber(owner as any); } else { return owner.name || ''; } @@ -5371,7 +5371,7 @@ export function attach( if (instance !== undefined) { if (instance.kind === FILTERED_FIBER_INSTANCE) { // A Filtered Fiber Instance will always have a Virtual Instance as a parent. - return ((instance.parent: any): VirtualInstance).id; + return (instance.parent as any as VirtualInstance).id; } return instance.id; } @@ -5406,7 +5406,7 @@ export function attach( ): mixed { if (isMostRecentlyInspectedElement(id)) { return getInObject( - ((mostRecentlyInspectedElement: any): InspectedElement), + mostRecentlyInspectedElement as any as InspectedElement, path, ); } @@ -5532,21 +5532,21 @@ export function attach( return null; } if (typeof owner.tag === 'number') { - const ownerFiber: Fiber = (owner: any); // Refined + const ownerFiber: Fiber = owner as any; // Refined owner = ownerFiber._debugOwner; } else { - const ownerInfo: ReactComponentInfo = (owner: any); // Refined + const ownerInfo: ReactComponentInfo = owner as any; // Refined owner = ownerInfo.owner; } while (owner) { if (typeof owner.tag === 'number') { - const ownerFiber: Fiber = (owner: any); // Refined + const ownerFiber: Fiber = owner as any; // Refined if (!shouldFilterFiber(ownerFiber)) { return ownerFiber; } owner = ownerFiber._debugOwner; } else { - const ownerInfo: ReactComponentInfo = (owner: any); // Refined + const ownerInfo: ReactComponentInfo = owner as any; // Refined if (!shouldFilterVirtual(ownerInfo, null)) { return ownerInfo; } @@ -5572,7 +5572,7 @@ export function attach( // isn't propagated down as the new owner. In that case we might match the alternate // instead. This is a bit hacky but the fastest check since type casting owner to a Fiber // needs a duck type check anyway. - parentInstance.data === (owner: any).alternate + parentInstance.data === (owner as any).alternate ) { if (parentInstance.kind === FILTERED_FIBER_INSTANCE) { return null; @@ -5653,7 +5653,7 @@ export function attach( } let firstInstance: null | DevToolsInstance = null; if (filterByChildInstance === null) { - firstInstance = (set.values().next().value: any); + firstInstance = set.values().next().value as any; } else { // eslint-disable-next-line no-for-of-loops/no-for-of-loops for (const childInstance of set.values()) { @@ -6089,7 +6089,7 @@ export function attach( ? inspectRootsRaw(devtoolsInstance.id) : inspectFiberInstanceRaw(devtoolsInstance); } - (devtoolsInstance: FilteredFiberInstance); // assert exhaustive + devtoolsInstance as FilteredFiberInstance; // assert exhaustive throw new Error('Unsupported instance kind'); } @@ -6170,7 +6170,7 @@ export function attach( context = consumerResolvedContext._currentValue || null; // Look for overridden value. - let current = ((fiber: any): Fiber).return; + let current = (fiber as any as Fiber).return; while (current !== null) { const currentType = current.type; const currentTypeSymbol = getTypeSymbol(currentType); @@ -6203,7 +6203,7 @@ export function attach( context = consumerResolvedContext._currentValue || null; // Look for overridden value. - let current = ((fiber: any): Fiber).return; + let current = (fiber as any as Fiber).return; while (current !== null) { const currentType = current.type; const currentTypeSymbol = getTypeSymbol(currentType); @@ -6703,7 +6703,7 @@ export function attach( ): void { if (isMostRecentlyInspectedElement(id)) { const value = getInObject( - ((mostRecentlyInspectedElement: any): InspectedElement), + mostRecentlyInspectedElement as any as InspectedElement, path, ); const key = `$reactTemp${count}`; @@ -6721,7 +6721,7 @@ export function attach( ): ?string { if (isMostRecentlyInspectedElement(id)) { const valueToCopy = getInObject( - ((mostRecentlyInspectedElement: any): InspectedElement), + mostRecentlyInspectedElement as any as InspectedElement, path, ); @@ -6756,7 +6756,7 @@ export function attach( path, value: cleanForBridge( getInObject( - ((mostRecentlyInspectedElement: any): InspectedElement), + mostRecentlyInspectedElement as any as InspectedElement, path, ), createIsPathAllowed(null, secondaryCategory), @@ -7071,7 +7071,7 @@ export function attach( break; case 'hooks': if (typeof overrideHookStateDeletePath === 'function') { - overrideHookStateDeletePath(fiber, ((hookID: any): number), path); + overrideHookStateDeletePath(fiber, hookID as any as number, path); } break; case 'props': @@ -7145,7 +7145,7 @@ export function attach( if (typeof overrideHookStateRenamePath === 'function') { overrideHookStateRenamePath( fiber, - ((hookID: any): number), + hookID as any as number, oldPath, newPath, ); @@ -7227,7 +7227,7 @@ export function attach( break; case 'hooks': if (typeof overrideHookState === 'function') { - overrideHookState(fiber, ((hookID: any): number), path, value); + overrideHookState(fiber, hookID as any as number, path, value); } break; case 'props': @@ -7445,13 +7445,16 @@ export function attach( ); } const rootID = rootInstance.id; - ((displayNamesByRootID: any): DisplayNamesByRootID).set( + (displayNamesByRootID as any as DisplayNamesByRootID).set( rootID, getDisplayNameForRoot(root.current), ); const initialTreeBaseDurations: Array<[number, number]> = []; snapshotTreeBaseDurations(rootInstance, initialTreeBaseDurations); - (initialTreeBaseDurationsMap: any).set(rootID, initialTreeBaseDurations); + (initialTreeBaseDurationsMap as any).set( + rootID, + initialTreeBaseDurations, + ); }); isProfiling = true; @@ -8113,7 +8116,7 @@ export function attach( // but it's at least somewhere within it. if (isError(unresolvedSource)) { return (instance.source = extractLocationFromOwnerStack( - (unresolvedSource: any), + unresolvedSource as any, )); } if (typeof unresolvedSource === 'string') { diff --git a/packages/react-devtools-shared/src/backend/fiber/shared/DevToolsFiberInspection.js b/packages/react-devtools-shared/src/backend/fiber/shared/DevToolsFiberInspection.js index 58c86f7cac09..c827753a78fb 100644 --- a/packages/react-devtools-shared/src/backend/fiber/shared/DevToolsFiberInspection.js +++ b/packages/react-devtools-shared/src/backend/fiber/shared/DevToolsFiberInspection.js @@ -21,7 +21,7 @@ export function isError(object: mixed): boolean { export function getFiberFlags(fiber: Fiber): number { // The name of this field changed from "effectTag" to "flags" - return fiber.flags !== undefined ? fiber.flags : (fiber: any).effectTag; + return fiber.flags !== undefined ? fiber.flags : (fiber as any).effectTag; } export function rootSupportsProfiling(root: any): boolean { @@ -61,7 +61,7 @@ export function getSecondaryEnvironmentName( index: number, ): null | string { if (debugInfo != null) { - const componentInfo: ReactComponentInfo = (debugInfo[index]: any); + const componentInfo: ReactComponentInfo = debugInfo[index] as any; for (let i = index + 1; i < debugInfo.length; i++) { const debugEntry = debugInfo[i]; if (typeof debugEntry.env === 'string') { diff --git a/packages/react-devtools-shared/src/backend/fiber/shared/DevToolsFiberInternalReactConstants.js b/packages/react-devtools-shared/src/backend/fiber/shared/DevToolsFiberInternalReactConstants.js index 053c519c887c..aa0449819f39 100644 --- a/packages/react-devtools-shared/src/backend/fiber/shared/DevToolsFiberInternalReactConstants.js +++ b/packages/react-devtools-shared/src/backend/fiber/shared/DevToolsFiberInternalReactConstants.js @@ -99,7 +99,7 @@ export function getInternalReactConstants(version: string): { const SuspenseyImagesMode = 0b0100000; - let ReactTypeOfWork: WorkTagMap = ((null: any): WorkTagMap); + let ReactTypeOfWork: WorkTagMap = null as any as WorkTagMap; // ********************************************************** // The section below is copied from files in React repo. diff --git a/packages/react-devtools-shared/src/backend/legacy/renderer.js b/packages/react-devtools-shared/src/backend/legacy/renderer.js index a908c727b182..07562065e712 100644 --- a/packages/react-devtools-shared/src/backend/legacy/renderer.js +++ b/packages/react-devtools-shared/src/backend/legacy/renderer.js @@ -146,7 +146,7 @@ export function attach( new WeakMap(); let getElementIDForHostInstance: GetElementIDForHostInstance = - ((null: any): GetElementIDForHostInstance); + null as any as GetElementIDForHostInstance; let findHostInstanceForInternalID: (id: number) => ?HostInstance; let getNearestMountedDOMNode = (node: Element): null | Element => { // Not implemented. @@ -198,7 +198,7 @@ export function attach( internalInstanceToIDMap.set(internalInstance, id); idToInternalInstanceMap.set(id, internalInstance); } - return ((internalInstanceToIDMap.get(internalInstance): any): number); + return internalInstanceToIDMap.get(internalInstance) as any as number; } function areEqualArrays(a: Array, b: Array) { @@ -832,7 +832,7 @@ export function attach( let owner = element._owner; if (owner) { - owners = ([]: Array); + owners = [] as Array; while (owner != null) { owners.push({ displayName: getData(owner).displayName || 'Unknown', diff --git a/packages/react-devtools-shared/src/backend/profilingHooks.js b/packages/react-devtools-shared/src/backend/profilingHooks.js index a3feb1748801..2a10eb5040f6 100644 --- a/packages/react-devtools-shared/src/backend/profilingHooks.js +++ b/packages/react-devtools-shared/src/backend/profilingHooks.js @@ -213,8 +213,8 @@ export function createProfilingHooks({ function markAndClear(markName: string) { // This method won't be called unless these functions are defined, so we can skip the extra typeof check. - ((performanceTarget: any): Performance).mark(markName); - ((performanceTarget: any): Performance).clearMarks(markName); + (performanceTarget as any as Performance).mark(markName); + (performanceTarget as any as Performance).clearMarks(markName); } function recordReactMeasureStarted( @@ -605,7 +605,7 @@ export function createProfilingHooks({ if (!wakeableIDs.has(wakeable)) { wakeableIDs.set(wakeable, wakeableID++); } - return ((wakeableIDs.get(wakeable): any): number); + return wakeableIDs.get(wakeable) as any as number; } function markComponentSuspended( @@ -626,7 +626,7 @@ export function createProfilingHooks({ // frameworks like Relay may also annotate Promises with a displayName, // describing what operation/data the thrown Promise is related to. // When this is available we should pass it along to the Timeline. - const displayName = (wakeable: any).displayName || ''; + const displayName = (wakeable as any).displayName || ''; let suspenseEvent: SuspenseEvent | null = null; // TODO (timeline) Record and cache component stack diff --git a/packages/react-devtools-shared/src/backend/shared/ReactSymbols.js b/packages/react-devtools-shared/src/backend/shared/ReactSymbols.js index 483671b90038..db5d05eb8da2 100644 --- a/packages/react-devtools-shared/src/backend/shared/ReactSymbols.js +++ b/packages/react-devtools-shared/src/backend/shared/ReactSymbols.js @@ -75,6 +75,6 @@ export const REACT_MEMO_CACHE_SENTINEL: symbol = Symbol.for( import type {ReactOptimisticKey} from 'shared/ReactTypes'; -export const REACT_OPTIMISTIC_KEY: ReactOptimisticKey = (Symbol.for( +export const REACT_OPTIMISTIC_KEY: ReactOptimisticKey = Symbol.for( 'react.optimistic_key', -): any); +) as any; diff --git a/packages/react-devtools-shared/src/backend/utils/index.js b/packages/react-devtools-shared/src/backend/utils/index.js index e9a8677000a0..816145fdb19d 100644 --- a/packages/react-devtools-shared/src/backend/utils/index.js +++ b/packages/react-devtools-shared/src/backend/utils/index.js @@ -61,7 +61,7 @@ export function copyWithDelete( const updated = isArray(obj) ? obj.slice() : {...obj}; if (index + 1 === path.length) { if (isArray(updated)) { - updated.splice(((key: any): number), 1); + updated.splice(key as any as number, 1); } else { delete updated[key]; } @@ -87,7 +87,7 @@ export function copyWithRename( // $FlowFixMe[incompatible-use] number or string is fine here updated[newKey] = updated[oldKey]; if (isArray(updated)) { - updated.splice(((oldKey: any): number), 1); + updated.splice(oldKey as any as number, 1); } else { delete updated[oldKey]; } diff --git a/packages/react-devtools-shared/src/backend/utils/parseStackTrace.js b/packages/react-devtools-shared/src/backend/utils/parseStackTrace.js index e18c2d7baa1b..109c12de37a9 100644 --- a/packages/react-devtools-shared/src/backend/utils/parseStackTrace.js +++ b/packages/react-devtools-shared/src/backend/utils/parseStackTrace.js @@ -224,12 +224,12 @@ function collectStackTrace( const enclosingLine: number = // $FlowFixMe[prop-missing] typeof callSite.getEnclosingLineNumber === 'function' - ? (callSite: any).getEnclosingLineNumber() || 0 + ? (callSite as any).getEnclosingLineNumber() || 0 : 0; const enclosingCol: number = // $FlowFixMe[prop-missing] typeof callSite.getEnclosingColumnNumber === 'function' - ? (callSite: any).getEnclosingColumnNumber() || 0 + ? (callSite as any).getEnclosingColumnNumber() || 0 : 0; const isAsync = // $FlowFixMe[prop-missing] diff --git a/packages/react-devtools-shared/src/backend/views/Highlighter/Highlighter.js b/packages/react-devtools-shared/src/backend/views/Highlighter/Highlighter.js index ddcb6f1ef11a..6fdd1ac7dc50 100644 --- a/packages/react-devtools-shared/src/backend/views/Highlighter/Highlighter.js +++ b/packages/react-devtools-shared/src/backend/views/Highlighter/Highlighter.js @@ -75,7 +75,7 @@ export function showOverlay( return isReactNativeEnvironment() ? showOverlayNative(elements, agent) : showOverlayWeb( - (elements: $ReadOnlyArray), + elements as $ReadOnlyArray, componentName, agent, hideAfterTimeout, diff --git a/packages/react-devtools-shared/src/backend/views/Highlighter/Overlay.js b/packages/react-devtools-shared/src/backend/views/Highlighter/Overlay.js index e55bdb4298c4..9384966b24d2 100644 --- a/packages/react-devtools-shared/src/backend/views/Highlighter/Overlay.js +++ b/packages/react-devtools-shared/src/backend/views/Highlighter/Overlay.js @@ -191,9 +191,9 @@ export default class Overlay { // We can't get the size of text nodes or comment nodes. React as of v15 // heavily uses comment nodes to delimit text. // TODO: We actually can measure text nodes. We should. - const elements: $ReadOnlyArray = (nodes.filter( + const elements: $ReadOnlyArray = nodes.filter( node => node.nodeType === Node.ELEMENT_NODE, - ): any); + ) as any; while (this.rects.length > elements.length) { const rect = this.rects.pop(); diff --git a/packages/react-devtools-shared/src/backend/views/Highlighter/index.js b/packages/react-devtools-shared/src/backend/views/Highlighter/index.js index 03397012b536..d0c6484b30b8 100644 --- a/packages/react-devtools-shared/src/backend/views/Highlighter/index.js +++ b/packages/react-devtools-shared/src/backend/views/Highlighter/index.js @@ -434,7 +434,7 @@ export default function setupHighlighter( lastHoveredNode = target; if (target.tagName === 'IFRAME') { - const iframe: HTMLIFrameElement = (target: any); + const iframe: HTMLIFrameElement = target as any; try { if (!iframesListeningTo.has(iframe)) { const window = iframe.contentWindow; @@ -493,9 +493,9 @@ export default function setupHighlighter( function getEventTarget(event: MouseEvent): HTMLElement { if (event.composed) { - return (event.composedPath()[0]: any); + return event.composedPath()[0] as any; } - return (event.target: any); + return event.target as any; } } diff --git a/packages/react-devtools-shared/src/backend/views/TraceUpdates/canvas.js b/packages/react-devtools-shared/src/backend/views/TraceUpdates/canvas.js index 6c7383183d06..56b6497d2d1b 100644 --- a/packages/react-devtools-shared/src/backend/views/TraceUpdates/canvas.js +++ b/packages/react-devtools-shared/src/backend/views/TraceUpdates/canvas.js @@ -48,7 +48,7 @@ function drawWeb(nodeToData: Map) { } const dpr = window.devicePixelRatio || 1; - const canvasFlow: HTMLCanvasElement = ((canvas: any): HTMLCanvasElement); + const canvasFlow: HTMLCanvasElement = canvas as any as HTMLCanvasElement; canvasFlow.width = window.innerWidth * dpr; canvasFlow.height = window.innerHeight * dpr; canvasFlow.style.width = `${window.innerWidth}px`; diff --git a/packages/react-devtools-shared/src/backend/views/TraceUpdates/index.js b/packages/react-devtools-shared/src/backend/views/TraceUpdates/index.js index 5b274e8a2f60..b7efe51337ab 100644 --- a/packages/react-devtools-shared/src/backend/views/TraceUpdates/index.js +++ b/packages/react-devtools-shared/src/backend/views/TraceUpdates/index.js @@ -47,7 +47,7 @@ export type Data = { const nodeToData: Map = new Map(); -let agent: Agent = ((null: any): Agent); +let agent: Agent = null as any as Agent; let drawAnimationFrameID: AnimationFrameID | null = null; let isEnabled: boolean = false; let redrawTimeoutID: TimeoutID | null = null; diff --git a/packages/react-devtools-shared/src/backendAPI.js b/packages/react-devtools-shared/src/backendAPI.js index c332393d2aa1..ae5641232971 100644 --- a/packages/react-devtools-shared/src/backendAPI.js +++ b/packages/react-devtools-shared/src/backendAPI.js @@ -204,7 +204,7 @@ function getPromiseForRequestID( const onInspectedElement = (data: any) => { if (data.responseID === requestID) { cleanup(); - resolve((data: T)); + resolve(data as T); } }; diff --git a/packages/react-devtools-shared/src/bridge.js b/packages/react-devtools-shared/src/bridge.js index 4ad87cceac4c..a568c22c392d 100644 --- a/packages/react-devtools-shared/src/bridge.js +++ b/packages/react-devtools-shared/src/bridge.js @@ -323,7 +323,7 @@ class Bridge< this._wallUnlisten = wall.listen((message: Message) => { if (message && message.event) { - (this: any).emit(message.event, message.payload); + (this as any).emit(message.event, message.payload); } }) || null; diff --git a/packages/react-devtools-shared/src/config/DevToolsFeatureFlags.core-fb.js b/packages/react-devtools-shared/src/config/DevToolsFeatureFlags.core-fb.js index 5d9c476b3bfd..684ca4d21cd0 100644 --- a/packages/react-devtools-shared/src/config/DevToolsFeatureFlags.core-fb.js +++ b/packages/react-devtools-shared/src/config/DevToolsFeatureFlags.core-fb.js @@ -27,4 +27,4 @@ import typeof * as FeatureFlagsType from './DevToolsFeatureFlags.default'; import typeof * as ExportsType from './DevToolsFeatureFlags.core-fb'; // Flow magic to verify the exports of this file match the original version. -((((null: any): ExportsType): FeatureFlagsType): ExportsType); +null as any as ExportsType as FeatureFlagsType as ExportsType; diff --git a/packages/react-devtools-shared/src/config/DevToolsFeatureFlags.core-oss.js b/packages/react-devtools-shared/src/config/DevToolsFeatureFlags.core-oss.js index 88b01afc3ee0..d506e05ad43f 100644 --- a/packages/react-devtools-shared/src/config/DevToolsFeatureFlags.core-oss.js +++ b/packages/react-devtools-shared/src/config/DevToolsFeatureFlags.core-oss.js @@ -27,4 +27,4 @@ import typeof * as FeatureFlagsType from './DevToolsFeatureFlags.default'; import typeof * as ExportsType from './DevToolsFeatureFlags.core-oss'; // Flow magic to verify the exports of this file match the original version. -((((null: any): ExportsType): FeatureFlagsType): ExportsType); +null as any as ExportsType as FeatureFlagsType as ExportsType; diff --git a/packages/react-devtools-shared/src/config/DevToolsFeatureFlags.extension-fb.js b/packages/react-devtools-shared/src/config/DevToolsFeatureFlags.extension-fb.js index 734e7988c858..2bf6eef6172e 100644 --- a/packages/react-devtools-shared/src/config/DevToolsFeatureFlags.extension-fb.js +++ b/packages/react-devtools-shared/src/config/DevToolsFeatureFlags.extension-fb.js @@ -27,4 +27,4 @@ import typeof * as FeatureFlagsType from './DevToolsFeatureFlags.default'; import typeof * as ExportsType from './DevToolsFeatureFlags.extension-fb'; // Flow magic to verify the exports of this file match the original version. -((((null: any): ExportsType): FeatureFlagsType): ExportsType); +null as any as ExportsType as FeatureFlagsType as ExportsType; diff --git a/packages/react-devtools-shared/src/config/DevToolsFeatureFlags.extension-oss.js b/packages/react-devtools-shared/src/config/DevToolsFeatureFlags.extension-oss.js index c9b665a9096e..dfafc3262ca4 100644 --- a/packages/react-devtools-shared/src/config/DevToolsFeatureFlags.extension-oss.js +++ b/packages/react-devtools-shared/src/config/DevToolsFeatureFlags.extension-oss.js @@ -27,4 +27,4 @@ import typeof * as FeatureFlagsType from './DevToolsFeatureFlags.default'; import typeof * as ExportsType from './DevToolsFeatureFlags.extension-oss'; // Flow magic to verify the exports of this file match the original version. -((((null: any): ExportsType): FeatureFlagsType): ExportsType); +null as any as ExportsType as FeatureFlagsType as ExportsType; diff --git a/packages/react-devtools-shared/src/devtools/ContextMenu/ContextMenu.js b/packages/react-devtools-shared/src/devtools/ContextMenu/ContextMenu.js index ded5bbb22e6c..5befb9ab57dd 100644 --- a/packages/react-devtools-shared/src/devtools/ContextMenu/ContextMenu.js +++ b/packages/react-devtools-shared/src/devtools/ContextMenu/ContextMenu.js @@ -84,10 +84,10 @@ export default function ContextMenu({ "Can't access context menu element. This is a bug in React DevTools.", ); } - const menu = (maybeMenu: HTMLDivElement); + const menu = maybeMenu as HTMLDivElement; function hideUnlessContains(event: Event) { - if (!menu.contains(((event.target: any): Node))) { + if (!menu.contains(event.target as any as Node)) { hide(); } } diff --git a/packages/react-devtools-shared/src/devtools/cache.js b/packages/react-devtools-shared/src/devtools/cache.js index c927b4d3dbf3..0473e38ee0a0 100644 --- a/packages/react-devtools-shared/src/devtools/cache.js +++ b/packages/react-devtools-shared/src/devtools/cache.js @@ -46,10 +46,10 @@ if (typeof React.use === 'function') { return React.use(Context); }; } else if ( - typeof (React: any).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED === + typeof (React as any).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED === 'object' ) { - const ReactCurrentDispatcher = (React: any) + const ReactCurrentDispatcher = (React as any) .__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher; readContext = function (Context: ReactContext) { const dispatcher = ReactCurrentDispatcher.current; @@ -79,9 +79,9 @@ const resourceConfigs: Map, Config> = new Map(); function getEntriesForResource( resource: any, ): Map | WeakMap { - let entriesForResource: Map | WeakMap = ((entries.get( + let entriesForResource: Map | WeakMap = entries.get( resource, - ): any): Map); + ) as any as Map; if (entriesForResource === undefined) { const config = resourceConfigs.get(resource); entriesForResource = @@ -103,12 +103,12 @@ function accessResult( const thenable = fetch(input); thenable.then( value => { - const fulfilledThenable: FulfilledThenable = (thenable: any); + const fulfilledThenable: FulfilledThenable = thenable as any; fulfilledThenable.status = 'fulfilled'; fulfilledThenable.value = value; }, error => { - const rejectedThenable: RejectedThenable = (thenable: any); + const rejectedThenable: RejectedThenable = thenable as any; rejectedThenable.status = 'rejected'; rejectedThenable.reason = error; }, @@ -171,9 +171,9 @@ export function createResource( write(key: Key, value: Value): void { const entriesForResource = getEntriesForResource(resource); - const fulfilledThenable: FulfilledThenable = (Promise.resolve( + const fulfilledThenable: FulfilledThenable = Promise.resolve( value, - ): any); + ) as any; fulfilledThenable.status = 'fulfilled'; fulfilledThenable.value = value; diff --git a/packages/react-devtools-shared/src/devtools/store.js b/packages/react-devtools-shared/src/devtools/store.js index 9fbb3beaab10..557020620e91 100644 --- a/packages/react-devtools-shared/src/devtools/store.js +++ b/packages/react-devtools-shared/src/devtools/store.js @@ -1313,7 +1313,7 @@ export default class Store extends EventEmitter<{ if (didMutate) { let weightAcrossRoots = 0; this._roots.forEach(rootID => { - const {weight} = ((this.getElementByID(rootID): any): Element); + const {weight} = this.getElementByID(rootID) as any as Element; weightAcrossRoots += weight; }); this._weightAcrossRoots = weightAcrossRoots; @@ -1426,7 +1426,7 @@ export default class Store extends EventEmitter<{ switch (operation) { case TREE_OPERATION_ADD: { const id = operations[i + 1]; - const type = ((operations[i + 2]: any): ElementType); + const type = operations[i + 2] as any as ElementType; i += 3; @@ -1820,7 +1820,7 @@ export default class Store extends EventEmitter<{ const parentID = operations[i + 2]; const nameStringID = operations[i + 3]; const isSuspended = operations[i + 4] === 1; - const numRects = ((operations[i + 5]: any): number); + const numRects = operations[i + 5] as any as number; let name = stringTable[nameStringID]; if (this._idToSuspense.has(id)) { @@ -2030,8 +2030,8 @@ export default class Store extends EventEmitter<{ break; } case SUSPENSE_TREE_OPERATION_RESIZE: { - const id = ((operations[i + 1]: any): number); - const numRects = ((operations[i + 2]: any): number); + const id = operations[i + 1] as any as number; + const numRects = operations[i + 2] as any as number; i += 3; const suspense = this._idToSuspense.get(id); @@ -2276,7 +2276,7 @@ export default class Store extends EventEmitter<{ if (didCollapse) { let weightAcrossRoots = 0; this._roots.forEach(rootID => { - const {weight} = ((this.getElementByID(rootID): any): Element); + const {weight} = this.getElementByID(rootID) as any as Element; weightAcrossRoots += weight; }); this._weightAcrossRoots = weightAcrossRoots; diff --git a/packages/react-devtools-shared/src/devtools/utils.js b/packages/react-devtools-shared/src/devtools/utils.js index 43d3ea6c837b..ba21ad0fe2b3 100644 --- a/packages/react-devtools-shared/src/devtools/utils.js +++ b/packages/react-devtools-shared/src/devtools/utils.js @@ -156,7 +156,7 @@ export function printStore( } store.roots.forEach(rootID => { - const {weight} = ((store.getElementByID(rootID): any): Element); + const {weight} = store.getElementByID(rootID) as any as Element; const maybeWeightLabel = includeWeight ? ` (${weight})` : ''; // Store does not (yet) expose a way to get errors/warnings per root. diff --git a/packages/react-devtools-shared/src/devtools/views/Components/Components.js b/packages/react-devtools-shared/src/devtools/views/Components/Components.js index 80b6d450331d..c1f14e6984ce 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/Components.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/Components.js @@ -239,4 +239,4 @@ function setResizeCSSVariable( } } -export default (portaledContent(Components): component()); +export default portaledContent(Components) as component(); diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContext.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContext.js index f6549fc243e4..922b564600a5 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContext.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContext.js @@ -57,7 +57,7 @@ type Context = { }; export const InspectedElementContext: ReactContext = - createContext(((null: any): Context)); + createContext(null as any as Context); export type Props = { children: ReactNodeList, diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContextTree.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContextTree.js index ac0b8a6a7739..129b3f76bf09 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContextTree.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContextTree.js @@ -81,7 +81,7 @@ export default function InspectedElementContextTree({ {isEmpty &&
None
} {/* $FlowFixMe[constant-condition] */} {!isEmpty && - (entries: any).map(([name, value]) => ( + (entries as any).map(([name, value]) => ( None} {/* $FlowFixMe[constant-condition] */} {!isEmpty && - (entries: any).map(([name, value]) => ( + (entries as any).map(([name, value]) => ( = createContext( - ((null: any): Context), + null as any as Context, ); NativeStyleContext.displayName = 'NativeStyleContext'; diff --git a/packages/react-devtools-shared/src/devtools/views/Components/OwnersListContext.js b/packages/react-devtools-shared/src/devtools/views/Components/OwnersListContext.js index 4044b93dc40a..9a89e3148820 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/OwnersListContext.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/OwnersListContext.js @@ -26,7 +26,7 @@ import type {Resource, Thenable} from '../../cache'; type Context = (id: number) => Array | null; const OwnersListContext: ReactContext = createContext( - ((null: any): Context), + null as any as Context, ); OwnersListContext.displayName = 'OwnersListContext'; @@ -52,7 +52,7 @@ const resource: Resource< | ResolveFn | (( result: Promise> | Array, - ) => void) = ((null: any): ResolveFn); + ) => void) = null as any as ResolveFn; const promise = new Promise(resolve => { resolveFn = resolve; }); @@ -60,7 +60,7 @@ const resource: Resource< // $FlowFixMe[incompatible-type] found when upgrading Flow inProgressRequests.set(element, {promise, resolveFn}); - return (promise: $FlowFixMe); + return promise as $FlowFixMe; }, (element: Element) => element, {useWeakMap: true}, @@ -88,7 +88,7 @@ function useChangeOwnerAction(): (nextOwnerID: number) => void { result: | Promise> | Array, - ) => void) = ((null: any): ResolveFn); + ) => void) = null as any as ResolveFn; const promise = new Promise(resolve => { resolveFn = resolve; }); diff --git a/packages/react-devtools-shared/src/devtools/views/Components/Tree.js b/packages/react-devtools-shared/src/devtools/views/Components/Tree.js index 5e79d0478bc5..be141e74a8cb 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/Tree.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/Tree.js @@ -215,7 +215,7 @@ export default function Tree(): React.Node { } const handleKeyDown = (event: KeyboardEvent) => { - if ((event: any).target.tagName === 'INPUT' || event.defaultPrevented) { + if ((event as any).target.tagName === 'INPUT' || event.defaultPrevented) { return; } diff --git a/packages/react-devtools-shared/src/devtools/views/Components/TreeContext.js b/packages/react-devtools-shared/src/devtools/views/Components/TreeContext.js index 58e86054d9ec..9ef558680fe1 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/TreeContext.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/TreeContext.js @@ -149,12 +149,12 @@ type Action = export type DispatcherContext = (action: Action) => void; const TreeStateContext: ReactContext = - createContext(((null: any): StateContext)); + createContext(null as any as StateContext); TreeStateContext.displayName = 'TreeStateContext'; // TODO: `dispatch` is an Action and should be named accordingly. const TreeDispatcherContext: ReactContext = - createContext(((null: any): DispatcherContext)); + createContext(null as any as DispatcherContext); TreeDispatcherContext.displayName = 'TreeDispatcherContext'; type State = { @@ -237,7 +237,7 @@ function reduceTreeState(store: Store, state: State, action: Action): State { case 'SELECT_ELEMENT_AT_INDEX': ownerSubtreeLeafElementID = null; - inspectedElementIndex = (action: ACTION_SELECT_ELEMENT_AT_INDEX) + inspectedElementIndex = (action as ACTION_SELECT_ELEMENT_AT_INDEX) .payload; break; case 'SELECT_ELEMENT_BY_ID': @@ -247,7 +247,7 @@ function reduceTreeState(store: Store, state: State, action: Action): State { // It might also cause problems if the specified element was inside of a (not yet expanded) subtree. lookupIDForIndex = false; - inspectedElementID = (action: ACTION_SELECT_ELEMENT_BY_ID).payload; + inspectedElementID = (action as ACTION_SELECT_ELEMENT_BY_ID).payload; inspectedElementIndex = inspectedElementID === null ? null @@ -270,7 +270,7 @@ function reduceTreeState(store: Store, state: State, action: Action): State { if (inspectedElementIndex !== null) { const selectedElement = store.getElementAtIndex( - ((inspectedElementIndex: any): number), + inspectedElementIndex as any as number, ); if (selectedElement !== null && selectedElement.parentID !== 0) { const parent = store.getElementByID(selectedElement.parentID); @@ -319,7 +319,7 @@ function reduceTreeState(store: Store, state: State, action: Action): State { } const selectedElement = store.getElementAtIndex( - ((inspectedElementIndex: any): number), + inspectedElementIndex as any as number, ); if (selectedElement !== null && selectedElement.ownerID !== 0) { const ownerIndex = store.getIndexOfElementID( @@ -336,7 +336,7 @@ function reduceTreeState(store: Store, state: State, action: Action): State { if (inspectedElementIndex !== null) { const selectedElement = store.getElementAtIndex( - ((inspectedElementIndex: any): number), + inspectedElementIndex as any as number, ); if (selectedElement !== null && selectedElement.parentID !== 0) { const parentIndex = store.getIndexOfElementID( @@ -362,7 +362,7 @@ function reduceTreeState(store: Store, state: State, action: Action): State { if (inspectedElementIndex !== null) { const selectedElement = store.getElementAtIndex( - ((inspectedElementIndex: any): number), + inspectedElementIndex as any as number, ); if (selectedElement !== null && selectedElement.parentID !== 0) { const parent = store.getElementByID(selectedElement.parentID); @@ -470,7 +470,7 @@ function reduceTreeState(store: Store, state: State, action: Action): State { inspectedElementID = null; } else { inspectedElementID = store.getElementIDAtIndex( - ((inspectedElementIndex: any): number), + inspectedElementIndex as any as number, ); } } @@ -520,15 +520,16 @@ function reduceSearchState(store: Store, state: State, action: Action): State { if (numPrevSearchResults > 0) { didRequestSearch = true; searchIndex = - ((searchIndex: any): number) > 0 - ? ((searchIndex: any): number) - 1 + (searchIndex as any as number) > 0 + ? (searchIndex as any as number) - 1 : numPrevSearchResults - 1; } break; case 'HANDLE_STORE_MUTATION': if (searchText !== '') { - const [addedElementIDs, removedElementIDs] = - (action: ACTION_HANDLE_STORE_MUTATION).payload; + const [addedElementIDs, removedElementIDs] = ( + action as ACTION_HANDLE_STORE_MUTATION + ).payload; removedElementIDs.forEach((parentID, id) => { // Prune this item from the search results. @@ -541,14 +542,16 @@ function reduceSearchState(store: Store, state: State, action: Action): State { // If the results are now empty, also deselect things. if (searchResults.length === 0) { searchIndex = null; - } else if (((searchIndex: any): number) >= searchResults.length) { + } else if ( + (searchIndex as any as number) >= searchResults.length + ) { searchIndex = searchResults.length - 1; } } }); addedElementIDs.forEach(id => { - const element = ((store.getElementByID(id): any): Element); + const element = store.getElementByID(id) as any as Element; // It's possible that multiple tree operations will fire before this action has run. // So it's important to check for elements that may have been added and then removed. @@ -559,16 +562,16 @@ function reduceSearchState(store: Store, state: State, action: Action): State { // Add this item to the search results if it matches. const regExp = createRegExp(searchText); if (displayName !== null && regExp.test(displayName)) { - const newElementIndex = ((store.getIndexOfElementID( + const newElementIndex = store.getIndexOfElementID( id, - ): any): number); + ) as any as number; let foundMatch = false; for (let index = 0; index < searchResults.length; index++) { const resultID = searchResults[index]; if ( newElementIndex < - ((store.getIndexOfElementID(resultID): any): number) + (store.getIndexOfElementID(resultID) as any as number) ) { foundMatch = true; searchResults = searchResults @@ -591,7 +594,7 @@ function reduceSearchState(store: Store, state: State, action: Action): State { case 'SET_SEARCH_TEXT': searchIndex = null; searchResults = []; - searchText = (action: ACTION_SET_SEARCH_TEXT).payload; + searchText = (action as ACTION_SET_SEARCH_TEXT).payload; if (searchText !== '') { const regExp = createRegExp(searchText); @@ -611,7 +614,7 @@ function reduceSearchState(store: Store, state: State, action: Action): State { } } else { searchIndex = Math.min( - ((prevSearchIndex: any): number), + prevSearchIndex as any as number, searchResults.length - 1, ); } @@ -638,9 +641,9 @@ function reduceSearchState(store: Store, state: State, action: Action): State { } } if (didRequestSearch && searchIndex !== null) { - inspectedElementID = ((searchResults[searchIndex]: any): number); + inspectedElementID = searchResults[searchIndex] as any as number; inspectedElementIndex = store.getIndexOfElementID( - ((inspectedElementID: any): number), + inspectedElementID as any as number, ); } @@ -706,13 +709,13 @@ function reduceOwnersState(store: Store, state: State, action: Action): State { break; case 'SELECT_ELEMENT_AT_INDEX': if (ownerFlatTree !== null) { - inspectedElementIndex = (action: ACTION_SELECT_ELEMENT_AT_INDEX) + inspectedElementIndex = (action as ACTION_SELECT_ELEMENT_AT_INDEX) .payload; } break; case 'SELECT_ELEMENT_BY_ID': if (ownerFlatTree !== null) { - const payload = (action: ACTION_SELECT_ELEMENT_BY_ID).payload; + const payload = (action as ACTION_SELECT_ELEMENT_BY_ID).payload; if (payload === null) { inspectedElementIndex = null; } else { @@ -752,7 +755,7 @@ function reduceOwnersState(store: Store, state: State, action: Action): State { // If the Store doesn't have any owners metadata, don't drill into an empty stack. // This is a confusing user experience. if (store.hasOwnerMetadata) { - ownerID = (action: ACTION_SELECT_OWNER).payload; + ownerID = (action as ACTION_SELECT_OWNER).payload; ownerFlatTree = store.getOwnersListForElement(ownerID); // Always force reset selection to be the top of the new owner tree. diff --git a/packages/react-devtools-shared/src/devtools/views/Components/ViewElementSourceContext.js b/packages/react-devtools-shared/src/devtools/views/Components/ViewElementSourceContext.js index 42f6b67723e8..9974c174fbac 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/ViewElementSourceContext.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/ViewElementSourceContext.js @@ -22,7 +22,7 @@ export type Context = { }; const ViewElementSourceContext: ReactContext = createContext( - ((null: any): Context), + null as any as Context, ); ViewElementSourceContext.displayName = 'ViewElementSourceContext'; diff --git a/packages/react-devtools-shared/src/devtools/views/DevTools.js b/packages/react-devtools-shared/src/devtools/views/DevTools.js index bf541f667287..1e36e43c9139 100644 --- a/packages/react-devtools-shared/src/devtools/views/DevTools.js +++ b/packages/react-devtools-shared/src/devtools/views/DevTools.js @@ -117,19 +117,19 @@ export type Props = { }; const componentsTab = { - id: ('components': TabID), + id: 'components' as TabID, icon: 'components', label: 'Components', title: 'React Components', }; const profilerTab = { - id: ('profiler': TabID), + id: 'profiler' as TabID, icon: 'profiler', label: 'Profiler', title: 'React Profiler', }; const suspenseTab = { - id: ('suspense': TabID), + id: 'suspense' as TabID, icon: 'suspense', label: 'Suspense', title: 'React Suspense', diff --git a/packages/react-devtools-shared/src/devtools/views/Editor/EditorPane.js b/packages/react-devtools-shared/src/devtools/views/Editor/EditorPane.js index 8237a59956d1..4930fab9a2e2 100644 --- a/packages/react-devtools-shared/src/devtools/views/Editor/EditorPane.js +++ b/packages/react-devtools-shared/src/devtools/views/Editor/EditorPane.js @@ -115,4 +115,4 @@ function EditorPane({selectedSource}: Props) { ); } -export default (portaledContent(EditorPane): component()); +export default portaledContent(EditorPane) as component(); diff --git a/packages/react-devtools-shared/src/devtools/views/ErrorBoundary/cache.js b/packages/react-devtools-shared/src/devtools/views/ErrorBoundary/cache.js index 6ae471ec993c..8ad55976582f 100644 --- a/packages/react-devtools-shared/src/devtools/views/ErrorBoundary/cache.js +++ b/packages/react-devtools-shared/src/devtools/views/ErrorBoundary/cache.js @@ -74,13 +74,13 @@ export function findGitHubIssue(errorMessage: string): GitHubIssue | null { }; const wake = () => { // This assumes they won't throw. - callbacks.forEach(callback => callback((thenable: any).value)); + callbacks.forEach(callback => callback((thenable as any).value)); callbacks.clear(); rejectCallbacks.clear(); }; const wakeRejections = () => { // This assumes they won't throw. - rejectCallbacks.forEach(callback => callback((thenable: any).reason)); + rejectCallbacks.forEach(callback => callback((thenable as any).reason)); rejectCallbacks.clear(); callbacks.clear(); }; @@ -96,20 +96,20 @@ export function findGitHubIssue(errorMessage: string): GitHubIssue | null { if (maybeItem) { const fulfilledThenable: FulfilledThenable = - (thenable: any); + thenable as any; fulfilledThenable.status = 'fulfilled'; fulfilledThenable.value = maybeItem; wake(); } else { const notFoundThenable: RejectedThenable = - (thenable: any); + thenable as any; notFoundThenable.status = 'rejected'; notFoundThenable.reason = null; wakeRejections(); } }) .catch(error => { - const rejectedThenable: RejectedThenable = (thenable: any); + const rejectedThenable: RejectedThenable = thenable as any; rejectedThenable.status = 'rejected'; rejectedThenable.reason = null; wakeRejections(); @@ -119,7 +119,7 @@ export function findGitHubIssue(errorMessage: string): GitHubIssue | null { setTimeout(() => { didTimeout = true; - const timedoutThenable: RejectedThenable = (thenable: any); + const timedoutThenable: RejectedThenable = thenable as any; timedoutThenable.status = 'rejected'; timedoutThenable.reason = null; wakeRejections(); diff --git a/packages/react-devtools-shared/src/devtools/views/InspectedElement/InspectedElementPane.js b/packages/react-devtools-shared/src/devtools/views/InspectedElement/InspectedElementPane.js index a47bffda8d7f..6abff0b01327 100644 --- a/packages/react-devtools-shared/src/devtools/views/InspectedElement/InspectedElementPane.js +++ b/packages/react-devtools-shared/src/devtools/views/InspectedElement/InspectedElementPane.js @@ -32,4 +32,4 @@ function InspectedElementPane() { ); } -export default (portaledContent(InspectedElementPane): component()); +export default portaledContent(InspectedElementPane) as component(); diff --git a/packages/react-devtools-shared/src/devtools/views/ModalDialog.js b/packages/react-devtools-shared/src/devtools/views/ModalDialog.js index a584d9a9e3d1..bb71e67e95f4 100644 --- a/packages/react-devtools-shared/src/devtools/views/ModalDialog.js +++ b/packages/react-devtools-shared/src/devtools/views/ModalDialog.js @@ -57,7 +57,7 @@ type ModalDialogContextType = { }; const ModalDialogContext: ReactContext = - createContext(((null: any): ModalDialogContextType)); + createContext(null as any as ModalDialogContextType); ModalDialogContext.displayName = 'ModalDialogContext'; function dialogReducer(state: State, action: Action) { diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/CommitFlamegraph.js b/packages/react-devtools-shared/src/devtools/views/Profiler/CommitFlamegraph.js index 3774a4d34004..4956516b8788 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/CommitFlamegraph.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/CommitFlamegraph.js @@ -57,13 +57,13 @@ export default function CommitFlamegraphAutoSizer(_: {}): React.Node { if (selectedCommitIndex !== null) { commitTree = profilingCache.getCommitTree({ commitIndex: selectedCommitIndex, - rootID: ((rootID: any): number), + rootID: rootID as any as number, }); chartData = profilingCache.getFlamegraphChartData({ commitIndex: selectedCommitIndex, commitTree, - rootID: ((rootID: any): number), + rootID: rootID as any as number, }); } @@ -75,8 +75,8 @@ export default function CommitFlamegraphAutoSizer(_: {}): React.Node { // Force Flow types to avoid checking for `null` here because there's no static proof that // by the time this render prop function is called, the values of the `let` variables have not changed. diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/CommitFlamegraphListItem.js b/packages/react-devtools-shared/src/devtools/views/Profiler/CommitFlamegraphListItem.js index 5bfe0a299f68..ac846b7be80d 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/CommitFlamegraphListItem.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/CommitFlamegraphListItem.js @@ -132,6 +132,6 @@ function CommitFlamegraphListItem({data, index, style}: Props): React.Node { ); } -export default (memo(CommitFlamegraphListItem, areEqual): component( +export default memo(CommitFlamegraphListItem, areEqual) as component( ...props: Props -)); +); diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/CommitRanked.js b/packages/react-devtools-shared/src/devtools/views/Profiler/CommitRanked.js index bc482776f4e8..57ed9983dd77 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/CommitRanked.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/CommitRanked.js @@ -57,13 +57,13 @@ export default function CommitRankedAutoSizer(_: {}): React.Node { if (selectedCommitIndex !== null) { commitTree = profilingCache.getCommitTree({ commitIndex: selectedCommitIndex, - rootID: ((rootID: any): number), + rootID: rootID as any as number, }); chartData = profilingCache.getRankedChartData({ commitIndex: selectedCommitIndex, commitTree, - rootID: ((rootID: any): number), + rootID: rootID as any as number, }); } @@ -73,8 +73,8 @@ export default function CommitRankedAutoSizer(_: {}): React.Node { {({height, width}) => ( diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/CommitRankedListItem.js b/packages/react-devtools-shared/src/devtools/views/Profiler/CommitRankedListItem.js index 707fddf6268c..99da9e9f0885 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/CommitRankedListItem.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/CommitRankedListItem.js @@ -79,6 +79,6 @@ function CommitRankedListItem({data, index, style}: Props) { ); } -export default (memo(CommitRankedListItem, areEqual): component( +export default memo(CommitRankedListItem, areEqual) as component( ...props: Props -)); +); diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js b/packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js index cdb50db8997d..d2b6eeb5d943 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js @@ -63,9 +63,9 @@ export function getCommitTree({ rootToCommitTreeMap.set(rootID, []); } - const commitTrees = ((rootToCommitTreeMap.get( + const commitTrees = rootToCommitTreeMap.get( rootID, - ): any): Array); + ) as any as Array; if (commitIndex < commitTrees.length) { return commitTrees[commitIndex]; } @@ -87,7 +87,7 @@ export function getCommitTree({ ); } - let commitTree: CommitTree = ((null: any): CommitTree); + let commitTree: CommitTree = null as any as CommitTree; for (let index = commitTrees.length; index <= commitIndex; index++) { // Commits are generated sequentially and cached. // If this is the very first commit, start with the cached snapshot and apply the first mutation. @@ -140,9 +140,9 @@ function recursivelyInitializeTree( hocDisplayNames: node.hocDisplayNames, key: node.key, parentID, - treeBaseDuration: ((dataForRoot.initialTreeBaseDurations.get( + treeBaseDuration: dataForRoot.initialTreeBaseDurations.get( id, - ): any): number), + ) as any as number, type: node.type, compiledWithForget: node.compiledWithForget, }); @@ -175,7 +175,7 @@ function updateTree( }; let i = 2; - let id: number = ((null: any): number); + let id: number = null as any as number; // Reassemble the string table. const stringTable: Array = [ @@ -199,8 +199,8 @@ function updateTree( switch (operation) { case TREE_OPERATION_ADD: { - id = ((operations[i + 1]: any): number); - const type = ((operations[i + 2]: any): ElementType); + id = operations[i + 1] as any as number; + const type = operations[i + 2] as any as ElementType; i += 3; @@ -235,7 +235,7 @@ function updateTree( nodes.set(id, node); } else { - const parentID = ((operations[i]: any): number); + const parentID = operations[i] as any as number; i++; i++; // ownerID @@ -283,11 +283,11 @@ function updateTree( break; } case TREE_OPERATION_REMOVE: { - const removeLength = ((operations[i + 1]: any): number); + const removeLength = operations[i + 1] as any as number; i += 2; for (let removeIndex = 0; removeIndex < removeLength; removeIndex++) { - id = ((operations[i]: any): number); + id = operations[i] as any as number; i++; if (!nodes.has(id)) { @@ -319,12 +319,12 @@ function updateTree( break; } case TREE_OPERATION_REORDER_CHILDREN: { - id = ((operations[i + 1]: any): number); - const numChildren = ((operations[i + 2]: any): number); - const children = ((operations.slice( + id = operations[i + 1] as any as number; + const numChildren = operations[i + 2] as any as number; + const children = operations.slice( i + 3, i + 3 + numChildren, - ): any): Array); + ) as any as Array; i = i + 3 + numChildren; @@ -414,19 +414,19 @@ function updateTree( } case SUSPENSE_TREE_OPERATION_REMOVE: { - const removeLength = ((operations[i + 1]: any): number); + const removeLength = operations[i + 1] as any as number; i += 2 + removeLength; break; } case SUSPENSE_TREE_OPERATION_REORDER_CHILDREN: { - const suspenseID = ((operations[i + 1]: any): number); - const numChildren = ((operations[i + 2]: any): number); - const children = ((operations.slice( + const suspenseID = operations[i + 1] as any as number; + const numChildren = operations[i + 2] as any as number; + const children = operations.slice( i + 3, i + 3 + numChildren, - ): any): Array); + ) as any as Array; i = i + 3 + numChildren; @@ -442,18 +442,18 @@ function updateTree( } case SUSPENSE_TREE_OPERATION_RESIZE: { - const suspenseID = ((operations[i + 1]: any): number); - const numRects = ((operations[i + 2]: any): number); + const suspenseID = operations[i + 1] as any as number; + const numRects = operations[i + 2] as any as number; // $FlowFixMe[constant-condition] if (__DEBUG__) { if (numRects === -1) { debug('Suspense resize', `suspense ${suspenseID} rects null`); } else { - const rects = ((operations.slice( + const rects = operations.slice( i + 3, i + 3 + numRects * 4, - ): any): Array); + ) as any as Array; debug( 'Suspense resize', `suspense ${suspenseID} rects [${rects.join(',')}]`, @@ -468,7 +468,7 @@ function updateTree( case SUSPENSE_TREE_OPERATION_SUSPENDERS: { i++; - const changeLength = ((operations[i++]: any): number); + const changeLength = operations[i++] as any as number; for (let changeIndex = 0; changeIndex < changeLength; changeIndex++) { const suspenseNodeId = operations[i++]; diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/FlamegraphChartBuilder.js b/packages/react-devtools-shared/src/devtools/views/Profiler/FlamegraphChartBuilder.js index 53f9f4965779..f61806096388 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/FlamegraphChartBuilder.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/FlamegraphChartBuilder.js @@ -52,7 +52,7 @@ export function getChartData({ const chartDataKey = `${rootID}-${commitIndex}`; if (cachedChartData.has(chartDataKey)) { - return ((cachedChartData.get(chartDataKey): any): ChartData); + return cachedChartData.get(chartDataKey) as any as ChartData; } const idToDepthMap: Map = new Map(); diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/HoveredFiberInfo.js b/packages/react-devtools-shared/src/devtools/views/Profiler/HoveredFiberInfo.js index a6dfeffb3e20..097d2bd7d735 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/HoveredFiberInfo.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/HoveredFiberInfo.js @@ -57,7 +57,7 @@ export default function HoveredFiberInfo({fiberData}: Props): React.Node { const commitIndex = commitIndices[i]; if (selectedCommitIndex === commitIndex) { const {fiberActualDurations, fiberSelfDurations} = - profilerStore.getCommitData(((rootID: any): number), commitIndex); + profilerStore.getCommitData(rootID as any as number, commitIndex); const actualDuration = fiberActualDurations.get(id) || 0; const selfDuration = fiberSelfDurations.get(id) || 0; diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/Profiler.js b/packages/react-devtools-shared/src/devtools/views/Profiler/Profiler.js index 6254be06d832..e9511e091627 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/Profiler.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/Profiler.js @@ -243,4 +243,4 @@ const tabsWithTimeline = [ }, ]; -export default (portaledContent(Profiler): component()); +export default portaledContent(Profiler) as component(); diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/ProfilerContext.js b/packages/react-devtools-shared/src/devtools/views/Profiler/ProfilerContext.js index d593558dbdd1..07d82a54b48c 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/ProfilerContext.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/ProfilerContext.js @@ -83,7 +83,7 @@ export type Context = { }; const ProfilerContext: ReactContext = createContext( - ((null: any): Context), + null as any as Context, ); ProfilerContext.displayName = 'ProfilerContext'; @@ -228,12 +228,12 @@ function ProfilerContextController({children}: Props): React.Node { // Always check didRecordCommits before using commitData or filteredCommitIndices. const commitData = useMemo(() => { if (!didRecordCommits || rootID === null || profilingData === null) { - return ([]: Array); + return [] as Array; } const dataForRoot = profilingData.dataForRoots.get(rootID); return dataForRoot ? dataForRoot.commitData - : ([]: Array); + : ([] as Array); }, [didRecordCommits, rootID, profilingData]); // Commit filtering and navigation diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/ProfilingImportExportButtons.js b/packages/react-devtools-shared/src/devtools/views/Profiler/ProfilingImportExportButtons.js index 6bb3e229fbd1..920785bad653 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/ProfilingImportExportButtons.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/ProfilingImportExportButtons.js @@ -86,7 +86,7 @@ export default function ProfilingImportExportButtons(): React.Node { // TODO (profiling) Handle fileReader errors. const fileReader = new FileReader(); fileReader.addEventListener('load', () => { - const raw = ((fileReader.result: any): string); + const raw = fileReader.result as any as string; const json = JSON.parse(raw); if (!isArray(json) && hasOwnProperty.call(json, 'version')) { @@ -95,7 +95,7 @@ export default function ProfilingImportExportButtons(): React.Node { setFile(null); try { - const profilingDataExport = ((json: any): ProfilingDataExport); + const profilingDataExport = json as any as ProfilingDataExport; profilerStore.profilingData = prepareProfilingDataFrontendFromExport(profilingDataExport); } catch (error) { diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/RankedChartBuilder.js b/packages/react-devtools-shared/src/devtools/views/Profiler/RankedChartBuilder.js index 8cec8c6b924f..5cded846bc4c 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/RankedChartBuilder.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/RankedChartBuilder.js @@ -48,7 +48,7 @@ export function getChartData({ const chartDataKey = `${rootID}-${commitIndex}`; if (cachedChartData.has(chartDataKey)) { - return ((cachedChartData.get(chartDataKey): any): ChartData); + return cachedChartData.get(chartDataKey) as any as ChartData; } let maxSelfDuration = 0; diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/SidebarSelectedFiberInfo.js b/packages/react-devtools-shared/src/devtools/views/Profiler/SidebarSelectedFiberInfo.js index 430f302fbf0a..9781d3e8901d 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/SidebarSelectedFiberInfo.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/SidebarSelectedFiberInfo.js @@ -97,7 +97,7 @@ export default function SidebarSelectedFiberInfo(): React.Node { const commitIndex = commitIndices[i]; const {duration, timestamp} = profilerStore.getCommitData( - ((rootID: any): number), + rootID as any as number, commitIndex, ); @@ -136,7 +136,7 @@ export default function SidebarSelectedFiberInfo(): React.Node { compiledWithForget={node.compiledWithForget} /> )} - + {listItems.length > 0 && (
diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitList.js b/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitList.js index 7b1cbcbdd261..356fa7e8b63a 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitList.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitList.js @@ -292,7 +292,11 @@ function List({ itemCount={filteredCommitIndices.length} itemData={itemData} itemSize={itemSize} - ref={(listRef: any) /* Flow bug? */} + ref={ + listRef as any + + /* Flow bug? */ + } width={width}> {SnapshotCommitListItem} diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitListItem.js b/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitListItem.js index d9f80f005319..263f50849d22 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitListItem.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitListItem.js @@ -96,6 +96,6 @@ function SnapshotCommitListItem({data: itemData, index, style}: Props) { ); } -export default (memo(SnapshotCommitListItem, areEqual): component( +export default memo(SnapshotCommitListItem, areEqual) as component( ...props: Props -)); +); diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js b/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js index 0d470ddb0003..6f1fa3ea43a9 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js @@ -32,7 +32,7 @@ export default function SnapshotSelector(_: Props): React.Node { } = useContext(ProfilerContext); const {profilerStore} = useContext(StoreContext); - const {commitData} = profilerStore.getDataForRoot(((rootID: any): number)); + const {commitData} = profilerStore.getDataForRoot(rootID as any as number); const totalDurations: Array = []; const commitTimes: Array = []; diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/WhatChanged.js b/packages/react-devtools-shared/src/devtools/views/Profiler/WhatChanged.js index dffcd03350cd..e8fd79e969be 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/WhatChanged.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/WhatChanged.js @@ -37,7 +37,7 @@ export default function WhatChanged({ } const {changeDescriptions} = profilerStore.getCommitData( - ((rootID: any): number), + rootID as any as number, selectedCommitIndex, ); diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/useCommitFilteringAndNavigation.js b/packages/react-devtools-shared/src/devtools/views/Profiler/useCommitFilteringAndNavigation.js index d3369b4f9538..b1b685de25a2 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/useCommitFilteringAndNavigation.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/useCommitFilteringAndNavigation.js @@ -60,7 +60,7 @@ export function useCommitFilteringAndNavigation( reduced.push(index); } return reduced; - }, ([]: Array)); + }, [] as Array); }, [commitData], ); diff --git a/packages/react-devtools-shared/src/devtools/views/Settings/ComponentsSettings.js b/packages/react-devtools-shared/src/devtools/views/Settings/ComponentsSettings.js index 9b73e949429b..81df5b7c9722 100644 --- a/packages/react-devtools-shared/src/devtools/views/Settings/ComponentsSettings.js +++ b/packages/react-devtools-shared/src/devtools/views/Settings/ComponentsSettings.js @@ -281,7 +281,7 @@ export default function ComponentsSettings({ if (index >= 0) { if (componentFilter.type === ComponentFilterElementType) { cloned[index] = { - ...((cloned[index]: any): ElementTypeComponentFilter), + ...(cloned[index] as any as ElementTypeComponentFilter), isEnabled, }; } else if ( @@ -289,17 +289,17 @@ export default function ComponentsSettings({ componentFilter.type === ComponentFilterLocation ) { cloned[index] = { - ...((cloned[index]: any): RegExpComponentFilter), + ...(cloned[index] as any as RegExpComponentFilter), isEnabled, }; } else if (componentFilter.type === ComponentFilterHOC) { cloned[index] = { - ...((cloned[index]: any): BooleanComponentFilter), + ...(cloned[index] as any as BooleanComponentFilter), isEnabled, }; } else if (componentFilter.type === ComponentFilterEnvironmentName) { cloned[index] = { - ...((cloned[index]: any): EnvironmentNameComponentFilter), + ...(cloned[index] as any as EnvironmentNameComponentFilter), isEnabled, }; } @@ -404,10 +404,10 @@ export default function ComponentsSettings({ onChange={({currentTarget}) => changeFilterType( componentFilter, - ((parseInt( + parseInt( currentTarget.value, 10, - ): any): ComponentFilterType), + ) as any as ComponentFilterType, ) }> {/* TODO: currently disabled, need find a new way of doing this @@ -445,7 +445,7 @@ export default function ComponentsSettings({ onChange={({currentTarget}) => updateFilterValueElementType( componentFilter, - ((parseInt(currentTarget.value, 10): any): ElementType), + parseInt(currentTarget.value, 10) as any as ElementType, ) }> {isInternalFacebookBuild && ( diff --git a/packages/react-devtools-shared/src/devtools/views/Settings/SettingsContext.js b/packages/react-devtools-shared/src/devtools/views/Settings/SettingsContext.js index c20249e89942..27bd47c349da 100644 --- a/packages/react-devtools-shared/src/devtools/views/Settings/SettingsContext.js +++ b/packages/react-devtools-shared/src/devtools/views/Settings/SettingsContext.js @@ -56,7 +56,7 @@ type Context = { }; const SettingsContext: ReactContext = createContext( - ((null: any): Context), + null as any as Context, ); SettingsContext.displayName = 'SettingsContext'; @@ -116,24 +116,24 @@ function SettingsContextController({ const documentElements = useMemo(() => { const array: Array = [ - ((document.documentElement: any): HTMLElement), + document.documentElement as any as HTMLElement, ]; if (componentsPortalContainer != null) { array.push( - ((componentsPortalContainer.ownerDocument - .documentElement: any): HTMLElement), + componentsPortalContainer.ownerDocument + .documentElement as any as HTMLElement, ); } if (profilerPortalContainer != null) { array.push( - ((profilerPortalContainer.ownerDocument - .documentElement: any): HTMLElement), + profilerPortalContainer.ownerDocument + .documentElement as any as HTMLElement, ); } if (suspensePortalContainer != null) { array.push( - ((suspensePortalContainer.ownerDocument - .documentElement: any): HTMLElement), + suspensePortalContainer.ownerDocument + .documentElement as any as HTMLElement, ); } return array; @@ -218,11 +218,11 @@ export function updateDisplayDensity( ): void { // Sizes and paddings/margins are all rem-based, // so update the root font-size as well when the display preference changes. - const computedStyle = getComputedStyle((document.body: any)); + const computedStyle = getComputedStyle(document.body as any); const fontSize = computedStyle.getPropertyValue( `--${displayDensity}-root-font-size`, ); - const root = ((document.querySelector(':root'): any): HTMLElement); + const root = document.querySelector(':root') as any as HTMLElement; root.style.fontSize = fontSize; } diff --git a/packages/react-devtools-shared/src/devtools/views/Settings/SettingsModalContext.js b/packages/react-devtools-shared/src/devtools/views/Settings/SettingsModalContext.js index f8f76053fc12..4ba7dd20139f 100644 --- a/packages/react-devtools-shared/src/devtools/views/Settings/SettingsModalContext.js +++ b/packages/react-devtools-shared/src/devtools/views/Settings/SettingsModalContext.js @@ -34,7 +34,7 @@ type Context = { }; const SettingsModalContext: ReactContext = createContext( - ((null: any): Context), + null as any as Context, ); SettingsModalContext.displayName = 'SettingsModalContext'; diff --git a/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseRects.js b/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseRects.js index a1a9f85411ce..b61ba892c33d 100644 --- a/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseRects.js +++ b/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseRects.js @@ -451,7 +451,7 @@ function SuspenseRectsTransition({id}: {id: Element['id']}): React$Node { }); } -const ViewBox = createContext((null: any)); +const ViewBox = createContext(null as any); function SuspenseRectsContainer({ scaleRef, diff --git a/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseTab.js b/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseTab.js index 3fdd9fe935a3..d59a037d38c9 100644 --- a/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseTab.js +++ b/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseTab.js @@ -645,4 +645,4 @@ function setResizeCSSVariable( } } -export default (portaledContent(SuspenseTab): component()); +export default portaledContent(SuspenseTab) as component(); diff --git a/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseTreeContext.js b/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseTreeContext.js index 4e07336b79f7..68dc5adb606e 100644 --- a/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseTreeContext.js +++ b/packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseTreeContext.js @@ -97,11 +97,11 @@ export type SuspenseTreeAction = export type SuspenseTreeDispatch = (action: SuspenseTreeAction) => void; const SuspenseTreeStateContext: ReactContext = - createContext(((null: any): SuspenseTreeState)); + createContext(null as any as SuspenseTreeState); SuspenseTreeStateContext.displayName = 'SuspenseTreeStateContext'; const SuspenseTreeDispatcherContext: ReactContext = - createContext(((null: any): SuspenseTreeDispatch)); + createContext(null as any as SuspenseTreeDispatch); SuspenseTreeDispatcherContext.displayName = 'SuspenseTreeDispatcherContext'; type Props = { diff --git a/packages/react-devtools-shared/src/devtools/views/TabBar.js b/packages/react-devtools-shared/src/devtools/views/TabBar.js index a277082ab264..4575c0ae8942 100644 --- a/packages/react-devtools-shared/src/devtools/views/TabBar.js +++ b/packages/react-devtools-shared/src/devtools/views/TabBar.js @@ -41,7 +41,7 @@ export default function TabBar({ type, }: Props): React.Node { if (!tabs.some(tab => tab !== null && tab.id === currentTab)) { - const firstTab = ((tabs.find(tab => tab !== null): any): TabInfo); + const firstTab = tabs.find(tab => tab !== null) as any as TabInfo; selectTab(firstTab.id); } diff --git a/packages/react-devtools-shared/src/devtools/views/context.js b/packages/react-devtools-shared/src/devtools/views/context.js index e04d3433c093..d2ff088c362e 100644 --- a/packages/react-devtools-shared/src/devtools/views/context.js +++ b/packages/react-devtools-shared/src/devtools/views/context.js @@ -15,11 +15,11 @@ import type {ViewAttributeSource} from 'react-devtools-shared/src/devtools/views import type {FrontendBridge} from 'react-devtools-shared/src/bridge'; export const BridgeContext: ReactContext = - createContext(((null: any): FrontendBridge)); + createContext(null as any as FrontendBridge); BridgeContext.displayName = 'BridgeContext'; export const StoreContext: ReactContext = createContext( - ((null: any): Store), + null as any as Store, ); StoreContext.displayName = 'StoreContext'; diff --git a/packages/react-devtools-shared/src/devtools/views/hooks.js b/packages/react-devtools-shared/src/devtools/views/hooks.js index 8589ea15d016..a861b3201f64 100644 --- a/packages/react-devtools-shared/src/devtools/views/hooks.js +++ b/packages/react-devtools-shared/src/devtools/views/hooks.js @@ -165,7 +165,7 @@ export function useLocalStorage( console.log(error); } if (typeof initialValue === 'function') { - return ((initialValue: any): () => T)(); + return (initialValue as any as () => T)(); } else { return initialValue; } @@ -188,7 +188,7 @@ export function useLocalStorage( (value: $FlowFixMe) => { try { const valueToStore = - value instanceof Function ? (value: any)(storedValue) : value; + value instanceof Function ? (value as any)(storedValue) : value; localStorageSetItem(key, JSON.stringify(valueToStore)); // Notify listeners that this setting has changed. diff --git a/packages/react-devtools-shared/src/devtools/views/utils.js b/packages/react-devtools-shared/src/devtools/views/utils.js index a2d254bc27d8..6fefc2fff1db 100644 --- a/packages/react-devtools-shared/src/devtools/views/utils.js +++ b/packages/react-devtools-shared/src/devtools/views/utils.js @@ -134,7 +134,7 @@ export function serializeDataForCopy(props: Object): string { export function serializeHooksForCopy(hooks: HooksTree | null): string { // $FlowFixMe[not-an-object] "HooksTree is not an object" - const cloned = Object.assign(([]: Array), hooks); + const cloned = Object.assign([] as Array, hooks); const queue = [...cloned]; diff --git a/packages/react-devtools-shared/src/dynamicImportCache.js b/packages/react-devtools-shared/src/dynamicImportCache.js index 726352cc933d..aa4add28b58b 100644 --- a/packages/react-devtools-shared/src/dynamicImportCache.js +++ b/packages/react-devtools-shared/src/dynamicImportCache.js @@ -93,7 +93,7 @@ export function loadModule(moduleLoaderFunction: ModuleLoaderFunction): Module { } // This assumes they won't throw. - rejectCallbacks.forEach(callback => callback((thenable: any).reason)); + rejectCallbacks.forEach(callback => callback((thenable as any).reason)); rejectCallbacks.clear(); callbacks.clear(); }; @@ -115,7 +115,7 @@ export function loadModule(moduleLoaderFunction: ModuleLoaderFunction): Module { return; } - const fulfilledThenable: FulfilledThenable = (thenable: any); + const fulfilledThenable: FulfilledThenable = thenable as any; fulfilledThenable.status = 'fulfilled'; fulfilledThenable.value = module; @@ -135,7 +135,7 @@ export function loadModule(moduleLoaderFunction: ModuleLoaderFunction): Module { console.log(error); - const rejectedThenable: RejectedThenable = (thenable: any); + const rejectedThenable: RejectedThenable = thenable as any; rejectedThenable.status = 'rejected'; rejectedThenable.reason = error; @@ -156,7 +156,7 @@ export function loadModule(moduleLoaderFunction: ModuleLoaderFunction): Module { didTimeout = true; - const rejectedThenable: RejectedThenable = (thenable: any); + const rejectedThenable: RejectedThenable = thenable as any; rejectedThenable.status = 'rejected'; rejectedThenable.reason = null; diff --git a/packages/react-devtools-shared/src/hook.js b/packages/react-devtools-shared/src/hook.js index f8778e584b87..5ec953101aa0 100644 --- a/packages/react-devtools-shared/src/hook.js +++ b/packages/react-devtools-shared/src/hook.js @@ -493,7 +493,7 @@ export function installHook( // The backend is what implements a message queue, so it's the only one that injects onErrorOrWarning. if (onErrorOrWarning != null) { onErrorOrWarning( - ((method: any): 'error' | 'warn'), + method as any as 'error' | 'warn', args.slice(), ); } @@ -699,19 +699,15 @@ export function installHook( }); } - Object.defineProperty( - target, - '__REACT_DEVTOOLS_GLOBAL_HOOK__', - ({ - // This property needs to be configurable for the test environment, - // else we won't be able to delete and recreate it between tests. - configurable: __DEV__, - enumerable: false, - get() { - return hook; - }, - }: Object), - ); + Object.defineProperty(target, '__REACT_DEVTOOLS_GLOBAL_HOOK__', { + // This property needs to be configurable for the test environment, + // else we won't be able to delete and recreate it between tests. + configurable: __DEV__, + enumerable: false, + get() { + return hook; + }, + } as Object); return hook; } diff --git a/packages/react-devtools-shared/src/hookNamesCache.js b/packages/react-devtools-shared/src/hookNamesCache.js index 0e3a043be17a..7123318cfb34 100644 --- a/packages/react-devtools-shared/src/hookNamesCache.js +++ b/packages/react-devtools-shared/src/hookNamesCache.js @@ -115,7 +115,7 @@ export function loadHookNames( } // This assumes they won't throw. - callbacks.forEach(callback => callback((thenable: any).value)); + callbacks.forEach(callback => callback((thenable as any).value)); callbacks.clear(); rejectCallbacks.clear(); }; @@ -125,7 +125,7 @@ export function loadHookNames( timeoutID = null; } // This assumes they won't throw. - rejectCallbacks.forEach(callback => callback((thenable: any).reason)); + rejectCallbacks.forEach(callback => callback((thenable as any).reason)); rejectCallbacks.clear(); callbacks.clear(); }; @@ -159,7 +159,7 @@ export function loadHookNames( if (hookNames) { const fulfilledThenable: FulfilledThenable = - (thenable: any); + thenable as any; fulfilledThenable.status = 'fulfilled'; fulfilledThenable.value = hookNames; status = 'success'; @@ -168,7 +168,7 @@ export function loadHookNames( wake(); } else { const notFoundThenable: RejectedThenable = - (thenable: any); + thenable as any; notFoundThenable.status = 'rejected'; notFoundThenable.reason = null; status = 'error'; @@ -190,7 +190,7 @@ export function loadHookNames( console.error(error); const rejectedThenable: RejectedThenable = - (thenable: any); + thenable as any; rejectedThenable.status = 'rejected'; rejectedThenable.reason = null; @@ -211,7 +211,7 @@ export function loadHookNames( didTimeout = true; - const timedoutThenable: RejectedThenable = (thenable: any); + const timedoutThenable: RejectedThenable = thenable as any; timedoutThenable.status = 'rejected'; timedoutThenable.reason = null; diff --git a/packages/react-devtools-shared/src/hooks/SourceMapConsumer.js b/packages/react-devtools-shared/src/hooks/SourceMapConsumer.js index 468905bf8716..a18ad15b50ec 100644 --- a/packages/react-devtools-shared/src/hooks/SourceMapConsumer.js +++ b/packages/react-devtools-shared/src/hooks/SourceMapConsumer.js @@ -39,9 +39,9 @@ export default function SourceMapConsumer( sourceMapJSON: MixedSourceMap | IndexSourceMapSection, ): SourceMapConsumerType { if (sourceMapJSON.sections != null) { - return IndexedSourceMapConsumer(((sourceMapJSON: any): IndexSourceMap)); + return IndexedSourceMapConsumer(sourceMapJSON as any as IndexSourceMap); } else { - return BasicSourceMapConsumer(((sourceMapJSON: any): BasicSourceMap)); + return BasicSourceMapConsumer(sourceMapJSON as any as BasicSourceMap); } } @@ -124,15 +124,15 @@ function BasicSourceMapConsumer(sourceMapJSON: BasicSourceMap) { return { column, line, - sourceContent: ((sourceContent: any): string | null), - sourceURL: ((sourceURL: any): string | null), + sourceContent: sourceContent as any as string | null, + sourceURL: sourceURL as any as string | null, ignored, }; } - return (({ + return { originalPositionFor, - }: any): SourceMapConsumerType); + } as any as SourceMapConsumerType; } type Section = { @@ -231,7 +231,7 @@ function IndexedSourceMapConsumer(sourceMapJSON: IndexSourceMap) { }); } - return (({ + return { originalPositionFor, - }: any): SourceMapConsumerType); + } as any as SourceMapConsumerType; } diff --git a/packages/react-devtools-shared/src/hooks/parseHookNames/loadSourceAndMetadata.js b/packages/react-devtools-shared/src/hooks/parseHookNames/loadSourceAndMetadata.js index fa4235dc2c2d..3bfc83dd2547 100644 --- a/packages/react-devtools-shared/src/hooks/parseHookNames/loadSourceAndMetadata.js +++ b/packages/react-devtools-shared/src/hooks/parseHookNames/loadSourceAndMetadata.js @@ -141,7 +141,7 @@ function extractAndLoadSourceMapJSON( locationKeyToHookSourceAndMetadata.forEach(hookSourceAndMetadata => { const sourceMapRegex = / ?sourceMappingURL=([^\s'"]+)/gm; const runtimeSourceCode = - ((hookSourceAndMetadata.runtimeSourceCode: any): string); + hookSourceAndMetadata.runtimeSourceCode as any as string; // TODO (named hooks) Search for our custom metadata first. // If it's found, we should use it rather than source maps. @@ -175,9 +175,11 @@ function extractAndLoadSourceMapJSON( // Web apps like Code Sandbox embed multiple inline source maps. // In this case, we need to loop through and find the right one. // We may also need to trim any part of this string that isn't based64 encoded data. - const trimmed = ((sourceMappingURL.match( - /base64,([a-zA-Z0-9+\/=]+)/, - ): any): Array)[1]; + const trimmed = ( + sourceMappingURL.match( + /base64,([a-zA-Z0-9+\/=]+)/, + ) as any as Array + )[1]; const decoded = withSyncPerfMeasurements( 'decodeBase64String()', () => decodeBase64String(trimmed), @@ -431,7 +433,7 @@ function initializeHookSourceAndMetadata( const locationKey = getHookSourceLocationKey(hookSource); if (!locationKeyToHookSourceAndMetadata.has(locationKey)) { // Can't be null because getHookSourceLocationKey() would have thrown - const runtimeSourceURL = ((hookSource.fileName: any): string); + const runtimeSourceURL = hookSource.fileName as any as string; const hookSourceAndMetadata: HookSourceAndMetadata = { hookSource, @@ -477,7 +479,7 @@ function loadSourceFiles( return withAsyncPerfMeasurements( `fetchFileWithCaching("${url}")`, () => { - return ((fetchFileWithCaching: any): FetchFileWithCaching)(url); + return (fetchFileWithCaching as any as FetchFileWithCaching)(url); }, ); }; diff --git a/packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js b/packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js index 14ab77896726..4e01d6b360a9 100644 --- a/packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js +++ b/packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js @@ -129,7 +129,7 @@ function findHookNames( hooksList.map(hook => { // We already guard against a null HookSource in parseHookNames() - const hookSource = ((hook.hookSource: any): HookSource); + const hookSource = hook.hookSource as any as HookSource; const fileName = hookSource.fileName; if (!fileName) { return null; // Should not be reachable. @@ -177,8 +177,8 @@ function findHookNames( getHookName( hook, hookParsedMetadata.originalSourceAST, - ((hookParsedMetadata.originalSourceCode: any): string), - ((originalSourceLineNumber: any): number), + hookParsedMetadata.originalSourceCode as any as string, + originalSourceLineNumber as any as number, originalSourceColumnNumber, ), ); @@ -255,7 +255,7 @@ function parseSourceAST( const {metadataConsumer, sourceMapConsumer} = hookParsedMetadata; const runtimeSourceCode = - ((hookSourceAndMetadata.runtimeSourceCode: any): string); + hookSourceAndMetadata.runtimeSourceCode as any as string; let hasHookMap = false; let originalSourceURL; let originalSourceCode; diff --git a/packages/react-devtools-shared/src/hydration.js b/packages/react-devtools-shared/src/hydration.js index 3670514ff4c6..d11c6220d4c5 100644 --- a/packages/react-devtools-shared/src/hydration.js +++ b/packages/react-devtools-shared/src/hydration.js @@ -26,15 +26,15 @@ import type { import noop from 'shared/noop'; export const meta = { - inspectable: (Symbol('inspectable'): symbol), - inspected: (Symbol('inspected'): symbol), - name: (Symbol('name'): symbol), - preview_long: (Symbol('preview_long'): symbol), - preview_short: (Symbol('preview_short'): symbol), - readonly: (Symbol('readonly'): symbol), - size: (Symbol('size'): symbol), - type: (Symbol('type'): symbol), - unserializable: (Symbol('unserializable'): symbol), + inspectable: Symbol('inspectable') as symbol, + inspected: Symbol('inspected') as symbol, + name: Symbol('name') as symbol, + preview_long: Symbol('preview_long') as symbol, + preview_short: Symbol('preview_short') as symbol, + readonly: Symbol('readonly') as symbol, + size: Symbol('size') as symbol, + type: Symbol('type') as symbol, + unserializable: Symbol('unserializable') as symbol, }; export type Dehydrated = { diff --git a/packages/react-devtools-shared/src/inspectedElementCache.js b/packages/react-devtools-shared/src/inspectedElementCache.js index 820baf3380dd..8a51e2543a9f 100644 --- a/packages/react-devtools-shared/src/inspectedElementCache.js +++ b/packages/react-devtools-shared/src/inspectedElementCache.js @@ -101,13 +101,13 @@ export function inspectElement( const wake = () => { // This assumes they won't throw. - callbacks.forEach(callback => callback((thenable: any).value)); + callbacks.forEach(callback => callback((thenable as any).value)); callbacks.clear(); rejectCallbacks.clear(); }; const wakeRejections = () => { // This assumes they won't throw. - rejectCallbacks.forEach(callback => callback((thenable: any).reason)); + rejectCallbacks.forEach(callback => callback((thenable as any).reason)); rejectCallbacks.clear(); callbacks.clear(); }; @@ -116,7 +116,7 @@ export function inspectElement( const rendererID = store.getRendererIDForElement(element.id); if (rendererID == null) { const rejectedThenable: RejectedThenable = - (thenable: any); + thenable as any; rejectedThenable.status = 'rejected'; rejectedThenable.reason = new Error( `Could not inspect element with id "${element.id}". No renderer found.`, @@ -133,7 +133,7 @@ export function inspectElement( InspectedElementResponseType, ]) => { const fulfilledThenable: FulfilledThenable = - (thenable: any); + thenable as any; fulfilledThenable.status = 'fulfilled'; fulfilledThenable.value = inspectedElement; wake(); @@ -143,7 +143,7 @@ export function inspectElement( console.error(error); const rejectedThenable: RejectedThenable = - (thenable: any); + thenable as any; rejectedThenable.status = 'rejected'; rejectedThenable.reason = error; diff --git a/packages/react-devtools-shared/src/inspectedElementMutableSource.js b/packages/react-devtools-shared/src/inspectedElementMutableSource.js index 4db8c812f4ea..51612a1bb961 100644 --- a/packages/react-devtools-shared/src/inspectedElementMutableSource.js +++ b/packages/react-devtools-shared/src/inspectedElementMutableSource.js @@ -88,7 +88,7 @@ export function inspectElement( let inspectedElement; switch (type) { case 'error': { - const {message, stack, errorType} = ((data: any): InspectElementError); + const {message, stack, errorType} = data as any as InspectElementError; // create a different error class for each error type // and keep useful information from backend. @@ -124,7 +124,7 @@ export function inspectElement( throw Error(`Element "${id}" not found`); case 'full-data': - const fullData = ((data: any): InspectElementFullData); + const fullData = data as any as InspectElementFullData; // New data has come in. // We should replace the data in our local mutable copy. @@ -137,7 +137,7 @@ export function inspectElement( return [inspectedElement, type]; case 'hydrated-path': - const hydratedPathData = ((data: any): InspectElementHydratedPath); + const hydratedPathData = data as any as InspectElementHydratedPath; const {value} = hydratedPathData; // A path has been hydrated. diff --git a/packages/react-devtools-shared/src/utils.js b/packages/react-devtools-shared/src/utils.js index 69c4b5d8aa4f..22e4c444ddfa 100644 --- a/packages/react-devtools-shared/src/utils.js +++ b/packages/react-devtools-shared/src/utils.js @@ -138,7 +138,7 @@ export function getWrappedDisplayName( wrapperName: string, fallbackName?: string, ): string { - const displayName = (outerType: any)?.displayName; + const displayName = (outerType as any)?.displayName; return ( displayName || `${wrapperName}(${getDisplayName(innerType, fallbackName)})` ); @@ -251,8 +251,8 @@ export function printOperationsArray(operations: Array) { switch (operation) { case TREE_OPERATION_ADD: { - const id = ((operations[i + 1]: any): number); - const type = ((operations[i + 2]: any): ElementType); + const id = operations[i + 1] as any as number; + const type = operations[i + 2] as any as ElementType; i += 3; @@ -264,7 +264,7 @@ export function printOperationsArray(operations: Array) { i++; // supportsStrictMode i++; // hasOwnerMetadata } else { - const parentID = ((operations[i]: any): number); + const parentID = operations[i] as any as number; i++; i++; // ownerID @@ -283,11 +283,11 @@ export function printOperationsArray(operations: Array) { break; } case TREE_OPERATION_REMOVE: { - const removeLength = ((operations[i + 1]: any): number); + const removeLength = operations[i + 1] as any as number; i += 2; for (let removeIndex = 0; removeIndex < removeLength; removeIndex++) { - const id = ((operations[i]: any): number); + const id = operations[i] as any as number; i += 1; logs.push(`Remove node ${id}`); @@ -304,8 +304,8 @@ export function printOperationsArray(operations: Array) { break; } case TREE_OPERATION_REORDER_CHILDREN: { - const id = ((operations[i + 1]: any): number); - const numChildren = ((operations[i + 2]: any): number); + const id = operations[i + 1] as any as number; + const numChildren = operations[i + 2] as any as number; i += 3; const children = operations.slice(i, i + numChildren); i += numChildren; @@ -369,11 +369,11 @@ export function printOperationsArray(operations: Array) { break; } case SUSPENSE_TREE_OPERATION_REMOVE: { - const removeLength = ((operations[i + 1]: any): number); + const removeLength = operations[i + 1] as any as number; i += 2; for (let removeIndex = 0; removeIndex < removeLength; removeIndex++) { - const id = ((operations[i]: any): number); + const id = operations[i] as any as number; i += 1; logs.push(`Remove suspense node ${id}`); @@ -382,8 +382,8 @@ export function printOperationsArray(operations: Array) { break; } case SUSPENSE_TREE_OPERATION_REORDER_CHILDREN: { - const id = ((operations[i + 1]: any): number); - const numChildren = ((operations[i + 2]: any): number); + const id = operations[i + 1] as any as number; + const numChildren = operations[i + 2] as any as number; i += 3; const children = operations.slice(i, i + numChildren); i += numChildren; @@ -394,8 +394,8 @@ export function printOperationsArray(operations: Array) { break; } case SUSPENSE_TREE_OPERATION_RESIZE: { - const id = ((operations[i + 1]: any): number); - const numRects = ((operations[i + 2]: any): number); + const id = operations[i + 1] as any as number; + const numRects = operations[i + 2] as any as number; i += 3; if (numRects === -1) { @@ -422,7 +422,7 @@ export function printOperationsArray(operations: Array) { } case SUSPENSE_TREE_OPERATION_SUSPENDERS: { i++; - const changeLength = ((operations[i++]: any): number); + const changeLength = operations[i++] as any as number; for (let changeIndex = 0; changeIndex < changeLength; changeIndex++) { const id = operations[i++]; @@ -651,7 +651,7 @@ export function deletePathInObject( const parent = getInObject(object, path.slice(0, length - 1)); if (parent) { if (isArray(parent)) { - parent.splice(((last: any): number), 1); + parent.splice(last as any as number, 1); } else { delete parent[last]; } @@ -672,7 +672,7 @@ export function renamePathInObject( const lastNew = newPath[length - 1]; parent[lastNew] = parent[lastOld]; if (isArray(parent)) { - parent.splice(((lastOld: any): number), 1); + parent.splice(lastOld as any as number, 1); } else { delete parent[lastOld]; } diff --git a/packages/react-devtools-shell/src/app/DeeplyNestedComponents/index.js b/packages/react-devtools-shell/src/app/DeeplyNestedComponents/index.js index f1369896eda0..5cfdb11c0d31 100644 --- a/packages/react-devtools-shell/src/app/DeeplyNestedComponents/index.js +++ b/packages/react-devtools-shell/src/app/DeeplyNestedComponents/index.js @@ -15,7 +15,7 @@ function wrapWithHoc(Component: () => any, index: number) { return ; } - const displayName = (Component: any).displayName || Component.name; + const displayName = (Component as any).displayName || Component.name; HOC.displayName = `withHoc${index}(${displayName})`; return HOC; diff --git a/packages/react-devtools-shell/src/app/InspectableElements/CustomHooks.js b/packages/react-devtools-shell/src/app/InspectableElements/CustomHooks.js index c0a543d44147..26af74714037 100644 --- a/packages/react-devtools-shell/src/app/InspectableElements/CustomHooks.js +++ b/packages/react-devtools-shell/src/app/InspectableElements/CustomHooks.js @@ -122,8 +122,8 @@ function wrapWithHoc( } const HocWithHooks = wrapWithHoc(FunctionWithHooks); -const Suspendender = React.lazy(() => { - return new Promise(resolve => { +const Suspendender = React.lazy<() => React.Node>(() => { + return new Promise<{default: () => React.Node, ...}>(resolve => { setTimeout(() => { resolve({ default: () => 'Finished!', diff --git a/packages/react-devtools-shell/src/app/ToDoList/ListItem.js b/packages/react-devtools-shell/src/app/ToDoList/ListItem.js index 549d15c31ea2..d8dbb721e858 100644 --- a/packages/react-devtools-shell/src/app/ToDoList/ListItem.js +++ b/packages/react-devtools-shell/src/app/ToDoList/ListItem.js @@ -46,4 +46,4 @@ function ListItem({item, removeItem, toggleItem}: Props) { ); } -export default (memo(ListItem): component(...props: Props)); +export default memo(ListItem) as component(...props: Props); diff --git a/packages/react-devtools-shell/src/app/devtools.js b/packages/react-devtools-shell/src/app/devtools.js index 8f3de74cf67c..dcf9b46afc74 100644 --- a/packages/react-devtools-shell/src/app/devtools.js +++ b/packages/react-devtools-shell/src/app/devtools.js @@ -14,7 +14,7 @@ import {initDevTools} from 'react-devtools-shared/src/devtools'; // $FlowFixMe[cannot-resolve-name] __webpack_public_path__ = '/dist/'; // eslint-disable-line no-undef -const iframe = ((document.getElementById('target'): any): HTMLIFrameElement); +const iframe = document.getElementById('target') as any as HTMLIFrameElement; const {contentDocument, contentWindow} = iframe; @@ -31,13 +31,13 @@ const DevTools = initializeFrontend(contentWindow); // Otherwise the Store may miss important initial tree op codes. activateBackend(contentWindow); -const container = ((document.getElementById('devtools'): any): HTMLElement); +const container = document.getElementById('devtools') as any as HTMLElement; let isTestAppMounted = true; -const mountButton = ((document.getElementById( +const mountButton = document.getElementById( 'mountButton', -): any): HTMLButtonElement); +) as any as HTMLButtonElement; mountButton.addEventListener('click', function () { if (isTestAppMounted) { if (typeof window.unmountTestApp === 'function') { @@ -86,5 +86,5 @@ function inject(sourcePath: string, callback: () => void) { script.onload = callback; script.src = sourcePath; - ((contentDocument.body: any): HTMLBodyElement).appendChild(script); + (contentDocument.body as any as HTMLBodyElement).appendChild(script); } diff --git a/packages/react-devtools-shell/src/app/index.js b/packages/react-devtools-shell/src/app/index.js index 78cd9478362d..0207a8934c2f 100644 --- a/packages/react-devtools-shell/src/app/index.js +++ b/packages/react-devtools-shell/src/app/index.js @@ -54,7 +54,7 @@ const unmountFunctions: Array<() => void | boolean> = []; function createContainer() { const container = document.createElement('div'); - ((document.body: any): HTMLBodyElement).appendChild(container); + (document.body as any as HTMLBodyElement).appendChild(container); return container; } diff --git a/packages/react-devtools-shell/src/e2e-apps/ListApp.js b/packages/react-devtools-shell/src/e2e-apps/ListApp.js index 9cb17188b0ff..58183467696d 100644 --- a/packages/react-devtools-shell/src/e2e-apps/ListApp.js +++ b/packages/react-devtools-shell/src/e2e-apps/ListApp.js @@ -19,7 +19,7 @@ function List() { const inputRef = useRef(null); const addItem = () => { - const input = ((inputRef.current: any): HTMLInputElement); + const input = inputRef.current as any as HTMLInputElement; const text = input.value; input.value = ''; diff --git a/packages/react-devtools-shell/src/e2e-regression/app-legacy.js b/packages/react-devtools-shell/src/e2e-regression/app-legacy.js index 19ad2f0f6d95..54adbca81564 100644 --- a/packages/react-devtools-shell/src/e2e-regression/app-legacy.js +++ b/packages/react-devtools-shell/src/e2e-regression/app-legacy.js @@ -13,7 +13,7 @@ const version = process.env.E2E_APP_REACT_VERSION; function mountApp(App: () => React$Node) { const container = document.createElement('div'); - ((document.body: any): HTMLBodyElement).appendChild(container); + (document.body as any as HTMLBodyElement).appendChild(container); // $FlowFixMe[prop-missing]: These are removed in 19. ReactDOM.render(, container); diff --git a/packages/react-devtools-shell/src/e2e-regression/app.js b/packages/react-devtools-shell/src/e2e-regression/app.js index d0210d323570..2125369dde96 100644 --- a/packages/react-devtools-shell/src/e2e-regression/app.js +++ b/packages/react-devtools-shell/src/e2e-regression/app.js @@ -9,7 +9,7 @@ import ListApp from '../e2e-apps/ListApp'; function mountApp(App: () => React$Node) { const container = document.createElement('div'); - ((document.body: any): HTMLBodyElement).appendChild(container); + (document.body as any as HTMLBodyElement).appendChild(container); const root = ReactDOMClient.createRoot(container); root.render(); diff --git a/packages/react-devtools-shell/src/e2e/app.js b/packages/react-devtools-shell/src/e2e/app.js index 155c545e9ce6..265ebf8a7172 100644 --- a/packages/react-devtools-shell/src/e2e/app.js +++ b/packages/react-devtools-shell/src/e2e/app.js @@ -7,7 +7,7 @@ import * as ReactDOMClient from 'react-dom/client'; const container = document.createElement('div'); -((document.body: any): HTMLBodyElement).appendChild(container); +(document.body as any as HTMLBodyElement).appendChild(container); // TODO We may want to parameterize this app // so that it can load things other than just ToDoList. diff --git a/packages/react-devtools-shell/src/perf-regression/app.js b/packages/react-devtools-shell/src/perf-regression/app.js index 88308e0fcf34..4fa784d55233 100644 --- a/packages/react-devtools-shell/src/perf-regression/app.js +++ b/packages/react-devtools-shell/src/perf-regression/app.js @@ -9,7 +9,7 @@ import App from './apps/index'; function mountApp() { const container = document.createElement('div'); - ((document.body: any): HTMLBodyElement).appendChild(container); + (document.body as any as HTMLBodyElement).appendChild(container); const root = createRoot(container); root.render( diff --git a/packages/react-devtools-timeline/src/EventTooltip.js b/packages/react-devtools-timeline/src/EventTooltip.js index 3d3698c09f94..ab0a409d7ceb 100644 --- a/packages/react-devtools-timeline/src/EventTooltip.js +++ b/packages/react-devtools-timeline/src/EventTooltip.js @@ -293,7 +293,7 @@ const TooltipSchedulingEvent = ({ case 'schedule-force-update': lanes = schedulingEvent.lanes; laneLabels = lanes.map( - lane => ((data.laneToLabelMap.get(lane): any): string), + lane => data.laneToLabelMap.get(lane) as any as string, ); break; } @@ -441,7 +441,7 @@ const TooltipReactMeasure = ({ const [startTime, stopTime] = getBatchRange(batchUID, data); const laneLabels = lanes.map( - lane => ((data.laneToLabelMap.get(lane): any): string), + lane => data.laneToLabelMap.get(lane) as any as string, ); return ( diff --git a/packages/react-devtools-timeline/src/Timeline.js b/packages/react-devtools-timeline/src/Timeline.js index f209309bb0ab..5c427bd9b74c 100644 --- a/packages/react-devtools-timeline/src/Timeline.js +++ b/packages/react-devtools-timeline/src/Timeline.js @@ -57,7 +57,7 @@ export function Timeline(_: {}): React.Node { const [key, setKey] = useState(theme); useLayoutEffect(() => { const pollForTheme = () => { - if (updateColorsToMatchTheme(((ref.current: any): HTMLDivElement))) { + if (updateColorsToMatchTheme(ref.current as any as HTMLDivElement)) { clearInterval(intervalID); setKey(deferredTheme); } diff --git a/packages/react-devtools-timeline/src/TimelineContext.js b/packages/react-devtools-timeline/src/TimelineContext.js index 7835158e9895..a6f52f5fa9d3 100644 --- a/packages/react-devtools-timeline/src/TimelineContext.js +++ b/packages/react-devtools-timeline/src/TimelineContext.js @@ -41,7 +41,7 @@ export type Context = { }; const TimelineContext: ReactContext = createContext( - ((null: any): Context), + null as any as Context, ); TimelineContext.displayName = 'TimelineContext'; diff --git a/packages/react-devtools-timeline/src/TimelineSearchContext.js b/packages/react-devtools-timeline/src/TimelineSearchContext.js index 604dbf180607..2a38dbcfd8c3 100644 --- a/packages/react-devtools-timeline/src/TimelineSearchContext.js +++ b/packages/react-devtools-timeline/src/TimelineSearchContext.js @@ -125,7 +125,7 @@ export type Context = { }; const TimelineSearchContext: ReactContext = createContext( - ((null: any): Context), + null as any as Context, ); TimelineSearchContext.displayName = 'TimelineSearchContext'; diff --git a/packages/react-devtools-timeline/src/content-views/ComponentMeasuresView.js b/packages/react-devtools-timeline/src/content-views/ComponentMeasuresView.js index 0e4a5727e20b..dc1c68045e32 100644 --- a/packages/react-devtools-timeline/src/content-views/ComponentMeasuresView.js +++ b/packages/react-devtools-timeline/src/content-views/ComponentMeasuresView.js @@ -113,8 +113,8 @@ export class ComponentMeasuresView extends View { return false; // Too small to render at this zoom level } - let textFillStyle = ((null: any): string); - let typeLabel = ((null: any): string); + let textFillStyle = null as any as string; + let typeLabel = null as any as string; const drawableRect = intersectionOfRects(componentMeasureRect, rect); context.beginPath(); diff --git a/packages/react-devtools-timeline/src/content-views/SuspenseEventsView.js b/packages/react-devtools-timeline/src/content-views/SuspenseEventsView.js index 43df27e8c92b..3c1fe88e91f7 100644 --- a/packages/react-devtools-timeline/src/content-views/SuspenseEventsView.js +++ b/packages/react-devtools-timeline/src/content-views/SuspenseEventsView.js @@ -122,7 +122,7 @@ export class SuspenseEventsView extends View { baseY += depth * ROW_WITH_BORDER_HEIGHT; - let fillStyle = ((null: any): string); + let fillStyle = null as any as string; if (warning !== null) { fillStyle = showHoverHighlight ? COLORS.WARNING_BACKGROUND_HOVER diff --git a/packages/react-devtools-timeline/src/content-views/utils/text.js b/packages/react-devtools-timeline/src/content-views/utils/text.js index 000a41cb0cdb..30b576c83bed 100644 --- a/packages/react-devtools-timeline/src/content-views/utils/text.js +++ b/packages/react-devtools-timeline/src/content-views/utils/text.js @@ -24,7 +24,7 @@ export function getTextWidth( cachedTextWidths.set(text, measuredWidth); } - return ((measuredWidth: any): number); + return measuredWidth as any as number; } export function trimText( diff --git a/packages/react-devtools-timeline/src/createDataResourceFromImportedFile.js b/packages/react-devtools-timeline/src/createDataResourceFromImportedFile.js index 2b8dfcd266a7..852ad542def5 100644 --- a/packages/react-devtools-timeline/src/createDataResourceFromImportedFile.js +++ b/packages/react-devtools-timeline/src/createDataResourceFromImportedFile.js @@ -22,9 +22,9 @@ export default function createDataResourceFromImportedFile( return createResource( () => { return new Promise((resolve, reject) => { - const promise = ((importFile( + const promise = importFile( file, - ): any): Promise); + ) as any as Promise; promise.then(data => { switch (data.status) { case 'SUCCESS': diff --git a/packages/react-devtools-timeline/src/import-worker/preprocessData.js b/packages/react-devtools-timeline/src/import-worker/preprocessData.js index f54b7b0f7870..50a3091b8eda 100644 --- a/packages/react-devtools-timeline/src/import-worker/preprocessData.js +++ b/packages/react-devtools-timeline/src/import-worker/preprocessData.js @@ -171,9 +171,11 @@ function markWorkStarted( // This array is pre-initialized before processing starts. lanes.forEach(lane => { - ((currentProfilerData.laneToReactMeasureMap.get( - lane, - ): any): ReactMeasure[]).push(measure); + ( + currentProfilerData.laneToReactMeasureMap.get( + lane, + ) as any as Array + ).push(measure); }); } @@ -362,7 +364,7 @@ function processScreenshot( }; // Delay processing until we've extracted snapshot dimensions. - let resolveFn = ((null: any): Function); + let resolveFn = null as any as Function; state.asyncProcessingPromises.push( new Promise(resolve => { resolveFn = resolve; @@ -551,7 +553,7 @@ function processTimelineEvent( currentProfilerData.thrownErrors.push({ componentName, message, - phase: ((phase: any): Phase), + phase: phase as any as Phase, timestamp: startTime, type: 'thrown-error', }); @@ -586,7 +588,7 @@ function processTimelineEvent( depth, duration: null, id, - phase: ((phase: any): Phase), + phase: phase as any as Phase, promiseName: promiseName || null, resolution: 'unresolved', timestamp: startTime, @@ -628,7 +630,7 @@ function processTimelineEvent( } else if (name.startsWith('--render-start-')) { if (state.nextRenderShouldGenerateNewBatchID) { state.nextRenderShouldGenerateNewBatchID = false; - state.batchUID = ((state.uidCounter++: any): BatchUID); + state.batchUID = state.uidCounter++ as any as BatchUID; } // If this render is the result of a nested update, make a note of it. diff --git a/packages/react-devtools-timeline/src/timelineCache.js b/packages/react-devtools-timeline/src/timelineCache.js index ee32e4440f0b..78b2516d8e3e 100644 --- a/packages/react-devtools-timeline/src/timelineCache.js +++ b/packages/react-devtools-timeline/src/timelineCache.js @@ -33,7 +33,7 @@ function readRecord(record: Thenable): T | Error { return React.use(record); } catch (x) { if (record.status === 'rejected') { - return (record.reason: any); + return record.reason as any; } throw x; } @@ -41,7 +41,7 @@ function readRecord(record: Thenable): T | Error { if (record.status === 'fulfilled') { return record.value; } else if (record.status === 'rejected') { - return (record.reason: any); + return record.reason as any; } else { throw record; } @@ -69,13 +69,13 @@ export function importFile(file: File): TimelineData | Error { const wake = () => { // This assumes they won't throw. - callbacks.forEach(callback => callback((thenable: any).value)); + callbacks.forEach(callback => callback((thenable as any).value)); callbacks.clear(); rejectCallbacks.clear(); }; const wakeRejections = () => { // This assumes they won't throw. - rejectCallbacks.forEach(callback => callback((thenable: any).reason)); + rejectCallbacks.forEach(callback => callback((thenable as any).reason)); rejectCallbacks.clear(); callbacks.clear(); }; @@ -86,7 +86,7 @@ export function importFile(file: File): TimelineData | Error { switch (data.status) { case 'SUCCESS': const fulfilledThenable: FulfilledThenable = - (thenable: any); + thenable as any; fulfilledThenable.status = 'fulfilled'; fulfilledThenable.value = data.processedData; wake(); @@ -94,7 +94,7 @@ export function importFile(file: File): TimelineData | Error { case 'INVALID_PROFILE_ERROR': case 'UNEXPECTED_ERROR': const rejectedThenable: RejectedThenable = - (thenable: any); + thenable as any; rejectedThenable.status = 'rejected'; rejectedThenable.reason = data.error; wakeRejections(); diff --git a/packages/react-devtools-timeline/src/utils/getBatchRange.js b/packages/react-devtools-timeline/src/utils/getBatchRange.js index 72bf119a0d11..d6f334761bd1 100644 --- a/packages/react-devtools-timeline/src/utils/getBatchRange.js +++ b/packages/react-devtools-timeline/src/utils/getBatchRange.js @@ -26,7 +26,7 @@ function unmemoizedGetBatchRange( throw Error(`Could not find measures with batch UID "${batchUID}"`); } - const lastMeasure = ((measures[measures.length - 1]: any): ReactMeasure); + const lastMeasure = measures[measures.length - 1] as any as ReactMeasure; const stopTime = lastMeasure.timestamp + lastMeasure.duration; if (stopTime < minStartTime) { diff --git a/packages/react-devtools-timeline/src/view-base/VerticalScrollView.js b/packages/react-devtools-timeline/src/view-base/VerticalScrollView.js index 06550e1f837b..d48c6083b865 100644 --- a/packages/react-devtools-timeline/src/view-base/VerticalScrollView.js +++ b/packages/react-devtools-timeline/src/view-base/VerticalScrollView.js @@ -249,9 +249,9 @@ export class VerticalScrollView extends View { if ( this._viewState.viewToMutableViewStateMap.has(this._mutableViewStateKey) ) { - this._scrollState = ((this._viewState.viewToMutableViewStateMap.get( + this._scrollState = this._viewState.viewToMutableViewStateMap.get( this._mutableViewStateKey, - ): any): ScrollState); + ) as any as ScrollState; } else { this._viewState.viewToMutableViewStateMap.set( this._mutableViewStateKey, diff --git a/packages/react-devtools-timeline/src/view-base/resizable/ResizableView.js b/packages/react-devtools-timeline/src/view-base/resizable/ResizableView.js index c66d9af3b503..024ff5056f3e 100644 --- a/packages/react-devtools-timeline/src/view-base/resizable/ResizableView.js +++ b/packages/react-devtools-timeline/src/view-base/resizable/ResizableView.js @@ -107,9 +107,9 @@ export class ResizableView extends View { if ( this._viewState.viewToMutableViewStateMap.has(this._mutableViewStateKey) ) { - this._layoutState = ((this._viewState.viewToMutableViewStateMap.get( + this._layoutState = this._viewState.viewToMutableViewStateMap.get( this._mutableViewStateKey, - ): any): LayoutState); + ) as any as LayoutState; this._updateLayoutStateAndResizeBar(this._layoutState.barOffsetY); } else { diff --git a/packages/react-dom-bindings/src/client/DOMAccessibilityRoles.js b/packages/react-dom-bindings/src/client/DOMAccessibilityRoles.js index 4c1091f2455c..c7f7161f62b2 100644 --- a/packages/react-dom-bindings/src/client/DOMAccessibilityRoles.js +++ b/packages/react-dom-bindings/src/client/DOMAccessibilityRoles.js @@ -80,7 +80,7 @@ function getImplicitRole(element: Element): string | null { } break; case 'INPUT': { - const type = (element: any).type; + const type = (element as any).type; switch (type) { case 'button': case 'image': @@ -111,7 +111,7 @@ function getImplicitRole(element: Element): string | null { } case 'SELECT': - if (element.hasAttribute('multiple') || (element: any).size > 1) { + if (element.hasAttribute('multiple') || (element as any).size > 1) { return 'listbox'; } return 'combobox'; diff --git a/packages/react-dom-bindings/src/client/DOMPropertyOperations.js b/packages/react-dom-bindings/src/client/DOMPropertyOperations.js index 72ed2ae4f924..2ba8ca79f5fa 100644 --- a/packages/react-dom-bindings/src/client/DOMPropertyOperations.js +++ b/packages/react-dom-bindings/src/client/DOMPropertyOperations.js @@ -46,7 +46,7 @@ export function getValueForAttribute( if (__DEV__) { checkAttributeStringCoercion(expected, name); } - if (value === '' + (expected: any)) { + if (value === '' + (expected as any)) { return expected; } return value; @@ -88,7 +88,7 @@ export function getValueForAttributeOnCustomComponent( if (__DEV__) { checkAttributeStringCoercion(expected, name); } - if (value === '' + (expected: any)) { + if (value === '' + (expected as any)) { return expected; } return value; @@ -126,7 +126,7 @@ export function setValueForAttribute( } node.setAttribute( name, - enableTrustedTypesIntegration ? (value: any) : '' + (value: any), + enableTrustedTypesIntegration ? (value as any) : '' + (value as any), ); } } @@ -154,7 +154,7 @@ export function setValueForKnownAttribute( } node.setAttribute( name, - enableTrustedTypesIntegration ? (value: any) : '' + (value: any), + enableTrustedTypesIntegration ? (value as any) : '' + (value as any), ); } @@ -183,7 +183,7 @@ export function setValueForNamespacedAttribute( node.setAttributeNS( namespace, name, - enableTrustedTypesIntegration ? (value: any) : '' + (value: any), + enableTrustedTypesIntegration ? (value as any) : '' + (value as any), ); } @@ -206,22 +206,22 @@ export function setValueForPropertyOnCustomComponent( if (typeof prevValue !== 'function' && prevValue !== null) { // If we previously assigned a non-function type into this node, then // remove it when switching to event listener mode. - if (name in (node: any)) { - (node: any)[name] = null; + if (name in (node as any)) { + (node as any)[name] = null; } else if (node.hasAttribute(name)) { node.removeAttribute(name); } } // $FlowFixMe[incompatible-type] value can't be casted to EventListener. - node.addEventListener(eventName, (value: EventListener), useCapture); + node.addEventListener(eventName, value as EventListener, useCapture); return; } } trackHostMutation(); - if (name in (node: any)) { - (node: any)[name] = value; + if (name in (node as any)) { + (node as any)[name] = value; return; } diff --git a/packages/react-dom-bindings/src/client/ReactDOMComponent.js b/packages/react-dom-bindings/src/client/ReactDOMComponent.js index 78376e4922a2..9ce8253d32a0 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMComponent.js +++ b/packages/react-dom-bindings/src/client/ReactDOMComponent.js @@ -250,7 +250,9 @@ function isExpectedViewTransitionName(htmlElement: HTMLElement): boolean { return false; } const expectedVtName = htmlElement.getAttribute('vt-name'); - const actualVtName: string = (htmlElement.style: any)['view-transition-name']; + const actualVtName: string = (htmlElement.style as any)[ + 'view-transition-name' + ]; if (expectedVtName) { return expectedVtName === actualVtName; } else { @@ -272,7 +274,7 @@ function warnForExtraAttributes( // Skip empty style. It's fine. return; } - const htmlElement = ((domElement: any): HTMLElement); + const htmlElement = domElement as any as HTMLElement; const style = htmlElement.style; const isOnlyVTStyles = (style.length === 1 && style[0] === 'view-transition-name') || @@ -326,7 +328,7 @@ function normalizeHTML(parent: Element, html: string) { parent.namespaceURI === MATH_NAMESPACE || parent.namespaceURI === SVG_NAMESPACE ? parent.ownerDocument.createElementNS( - (parent.namespaceURI: any), + parent.namespaceURI as any, parent.tagName, ) : parent.ownerDocument.createElement(parent.tagName); @@ -347,7 +349,8 @@ function normalizeMarkupForTextOrAttribute(markup: mixed): string { if (__DEV__) { checkHtmlStringCoercion(markup); } - const markupString = typeof markup === 'string' ? markup : '' + (markup: any); + const markupString = + typeof markup === 'string' ? markup : '' + (markup as any); return markupString .replace(NORMALIZE_NEWLINES_REGEX, '\n') .replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, ''); @@ -464,7 +467,7 @@ function setProp( if (__DEV__) { try { // This should always error. - URL.revokeObjectURL(URL.createObjectURL((value: any))); + URL.revokeObjectURL(URL.createObjectURL(value as any)); if (tag === 'source') { console.error( 'Passing Blob, MediaSource or MediaStream to is not supported. ' + @@ -525,9 +528,9 @@ function setProp( if (__DEV__) { checkAttributeStringCoercion(value, key); } - const sanitizedValue = (sanitizeURL( - enableTrustedTypesIntegration ? value : '' + (value: any), - ): any); + const sanitizedValue = sanitizeURL( + enableTrustedTypesIntegration ? value : '' + (value as any), + ) as any; domElement.setAttribute(key, sanitizedValue); break; } @@ -596,9 +599,9 @@ function setProp( if (__DEV__) { checkAttributeStringCoercion(value, key); } - const sanitizedValue = (sanitizeURL( - enableTrustedTypesIntegration ? value : '' + (value: any), - ): any); + const sanitizedValue = sanitizeURL( + enableTrustedTypesIntegration ? value : '' + (value as any), + ) as any; domElement.setAttribute(key, sanitizedValue); break; } @@ -608,7 +611,7 @@ function setProp( if (__DEV__ && typeof value !== 'function') { warnForInvalidEventListener(key, value); } - trapClickOnNonInteractiveElement(((domElement: any): HTMLElement)); + trapClickOnNonInteractiveElement(domElement as any as HTMLElement); } return; } @@ -658,12 +661,12 @@ function setProp( // Note: `option.selected` is not updated if `select.multiple` is // disabled with `removeAttribute`. We have special logic for handling this. case 'multiple': { - (domElement: any).multiple = + (domElement as any).multiple = value && typeof value !== 'function' && typeof value !== 'symbol'; break; } case 'muted': { - (domElement: any).muted = + (domElement as any).muted = value && typeof value !== 'function' && typeof value !== 'symbol'; break; } @@ -699,9 +702,9 @@ function setProp( if (__DEV__) { checkAttributeStringCoercion(value, key); } - const sanitizedValue = (sanitizeURL( - enableTrustedTypesIntegration ? value : '' + (value: any), - ): any); + const sanitizedValue = sanitizeURL( + enableTrustedTypesIntegration ? value : '' + (value as any), + ) as any; domElement.setAttributeNS(xlinkNamespace, 'xlink:href', sanitizedValue); break; } @@ -729,7 +732,7 @@ function setProp( } domElement.setAttribute( key, - enableTrustedTypesIntegration ? (value: any) : '' + (value: any), + enableTrustedTypesIntegration ? (value as any) : '' + (value as any), ); } else { domElement.removeAttribute(key); @@ -800,7 +803,7 @@ function setProp( if (__DEV__) { checkAttributeStringCoercion(value, key); } - domElement.setAttribute(key, (value: any)); + domElement.setAttribute(key, value as any); } else { domElement.removeAttribute(key); } @@ -816,12 +819,12 @@ function setProp( typeof value !== 'function' && typeof value !== 'symbol' && !isNaN(value) && - (value: any) >= 1 + (value as any) >= 1 ) { if (__DEV__) { checkAttributeStringCoercion(value, key); } - domElement.setAttribute(key, (value: any)); + domElement.setAttribute(key, value as any); } else { domElement.removeAttribute(key); } @@ -839,7 +842,7 @@ function setProp( if (__DEV__) { checkAttributeStringCoercion(value, key); } - domElement.setAttribute(key, (value: any)); + domElement.setAttribute(key, value as any); } else { domElement.removeAttribute(key); } @@ -1055,7 +1058,7 @@ function setPropOnCustomElement( if (__DEV__ && typeof value !== 'function') { warnForInvalidEventListener(key, value); } - trapClickOnNonInteractiveElement(((domElement: any): HTMLElement)); + trapClickOnNonInteractiveElement(domElement as any as HTMLElement); } return; } @@ -1344,7 +1347,7 @@ export function setInitialProperties( switch (propKey) { case 'selected': { // TODO: Remove support for selected on option. - (domElement: any).selected = + (domElement as any).selected = propValue && typeof propValue !== 'function' && typeof propValue !== 'symbol'; @@ -1824,7 +1827,7 @@ export function updateProperties( switch (propKey) { case 'selected': { // TODO: Remove support for selected on option. - (domElement: any).selected = false; + (domElement as any).selected = false; break; } default: { @@ -1847,7 +1850,7 @@ export function updateProperties( trackHostMutation(); } // TODO: Remove support for selected on option. - (domElement: any).selected = + (domElement as any).selected = nextProp && typeof nextProp !== 'function' && typeof nextProp !== 'symbol'; @@ -2021,7 +2024,7 @@ function getStylesObjectFromElement(domElement: Element): { [styleName: string]: string, } { const serverValueInObjectForm: {[prop: string]: string} = {}; - const htmlElement: HTMLElement = (domElement: any); + const htmlElement: HTMLElement = domElement as any; const style = htmlElement.style; for (let i = 0; i < style.length; i++) { const styleName: string = style[i]; @@ -2074,7 +2077,7 @@ function diffHydratedStyles( // Trailing semi-colon means this was regenerated. normalizedServerValue[normalizedServerValue.length - 1] === ';' && // TODO: Should we just ignore any style if the style as been manipulated? - hasViewTransition((domElement: any)) + hasViewTransition(domElement as any) ) { // If this had a view transition we might have applied a view transition // name/class and removed it. If that happens, the style attribute gets @@ -2250,7 +2253,7 @@ function hydrateBooleanishAttribute( if (__DEV__) { checkAttributeStringCoercion(value, attributeName); } - if (serverValue === '' + (value: any)) { + if (serverValue === '' + (value as any)) { return; } } @@ -2539,7 +2542,7 @@ function diffHydratedCustomComponent( continue; default: { // This is a DEV-only path - const hostContextDev: HostContextDev = (hostContext: any); + const hostContextDev: HostContextDev = hostContext as any; const hostContextProd = hostContextDev.context; if ( hostContextProd === HostContextNamespaceNone && @@ -2662,26 +2665,26 @@ function diffHydratedGenericElement( continue; case 'multiple': { extraAttributes.delete(propKey); - const serverValue = (domElement: any).multiple; + const serverValue = (domElement as any).multiple; warnForPropDifference(propKey, serverValue, value, serverDifferences); continue; } case 'muted': { extraAttributes.delete(propKey); - const serverValue = (domElement: any).muted; + const serverValue = (domElement as any).muted; warnForPropDifference(propKey, serverValue, value, serverDifferences); continue; } case 'autoFocus': { extraAttributes.delete('autofocus'); - const serverValue = (domElement: any).autofocus; + const serverValue = (domElement as any).autofocus; warnForPropDifference(propKey, serverValue, value, serverDifferences); continue; } case 'data': if (tag !== 'object') { extraAttributes.delete(propKey); - const serverValue = (domElement: any).getAttribute('data'); + const serverValue = (domElement as any).getAttribute('data'); warnForPropDifference(propKey, serverValue, value, serverDifferences); continue; } @@ -2692,7 +2695,7 @@ function diffHydratedGenericElement( if (tag === 'img' || tag === 'video' || tag === 'audio') { try { // Test if this is a compatible object - URL.revokeObjectURL(URL.createObjectURL((value: any))); + URL.revokeObjectURL(URL.createObjectURL(value as any)); hydrateSrcObjectAttribute( domElement, value, @@ -2707,7 +2710,7 @@ function diffHydratedGenericElement( if (__DEV__) { try { // This should always error. - URL.revokeObjectURL(URL.createObjectURL((value: any))); + URL.revokeObjectURL(URL.createObjectURL(value as any)); if (tag === 'source') { console.error( 'Passing Blob, MediaSource or MediaStream to is not supported. ' + @@ -3073,7 +3076,7 @@ function diffHydratedGenericElement( let isMismatchDueToBadCasing = false; // This is a DEV-only path - const hostContextDev: HostContextDev = (hostContext: any); + const hostContextDev: HostContextDev = hostContext as any; const hostContextProd = hostContextDev.context; if ( @@ -3264,7 +3267,7 @@ export function hydrateProperties( if (props.onClick != null) { // TODO: This cast may not be sound for SVG, MathML or custom elements. - trapClickOnNonInteractiveElement(((domElement: any): HTMLElement)); + trapClickOnNonInteractiveElement(domElement as any as HTMLElement); } return true; diff --git a/packages/react-dom-bindings/src/client/ReactDOMComponentTree.js b/packages/react-dom-bindings/src/client/ReactDOMComponentTree.js index 8438410e03a0..71b8630450f0 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMComponentTree.js +++ b/packages/react-dom-bindings/src/client/ReactDOMComponentTree.js @@ -72,22 +72,22 @@ export function detachDeletedInstance(node: Instance): void { if (enableInternalInstanceMap) { internalInstanceMap.delete(node); internalPropsMap.delete(node); - delete (node: any)[internalEventHandlersKey]; - delete (node: any)[internalEventHandlerListenersKey]; - delete (node: any)[internalEventHandlesSetKey]; - delete (node: any)[internalRootNodeResourcesKey]; + delete (node as any)[internalEventHandlersKey]; + delete (node as any)[internalEventHandlerListenersKey]; + delete (node as any)[internalEventHandlesSetKey]; + delete (node as any)[internalRootNodeResourcesKey]; if (__DEV__) { - delete (node: any)[internalInstanceKey]; + delete (node as any)[internalInstanceKey]; } return; } // TODO: This function is only called on host components. I don't think all of // these fields are relevant. - delete (node: any)[internalInstanceKey]; - delete (node: any)[internalPropsKey]; - delete (node: any)[internalEventHandlersKey]; - delete (node: any)[internalEventHandlerListenersKey]; - delete (node: any)[internalEventHandlesSetKey]; + delete (node as any)[internalInstanceKey]; + delete (node as any)[internalPropsKey]; + delete (node as any)[internalEventHandlersKey]; + delete (node as any)[internalEventHandlerListenersKey]; + delete (node as any)[internalEventHandlesSetKey]; } export function precacheFiberNode( @@ -102,11 +102,11 @@ export function precacheFiberNode( if (enableInternalInstanceMap) { internalInstanceMap.set(node, hostInst); if (__DEV__) { - (node: any)[internalInstanceKey] = hostInst; + (node as any)[internalInstanceKey] = hostInst; } return; } - (node: any)[internalInstanceKey] = hostInst; + (node as any)[internalInstanceKey] = hostInst; } export function markContainerAsRoot(hostRoot: Fiber, node: Container): void { @@ -135,9 +135,9 @@ export function isContainerMarkedAsRoot(node: Container): boolean { export function getClosestInstanceFromNode(targetNode: Node): null | Fiber { let targetInst: void | Fiber; if (enableInternalInstanceMap) { - targetInst = internalInstanceMap.get(((targetNode: any): InstanceUnion)); + targetInst = internalInstanceMap.get(targetNode as any as InstanceUnion); } else { - targetInst = (targetNode: any)[internalInstanceKey]; + targetInst = (targetNode as any)[internalInstanceKey]; } if (targetInst) { // Don't return HostRoot, SuspenseComponent or ActivityComponent here. @@ -157,12 +157,12 @@ export function getClosestInstanceFromNode(targetNode: Node): null | Fiber { // If it's not a container, we check if it's an instance. if (enableInternalInstanceMap) { targetInst = - (parentNode: any)[internalContainerInstanceKey] || - internalInstanceMap.get(((parentNode: any): InstanceUnion)); + (parentNode as any)[internalContainerInstanceKey] || + internalInstanceMap.get(parentNode as any as InstanceUnion); } else { targetInst = - (parentNode: any)[internalContainerInstanceKey] || - (parentNode: any)[internalInstanceKey]; + (parentNode as any)[internalContainerInstanceKey] || + (parentNode as any)[internalInstanceKey]; } if (targetInst) { // Since this wasn't the direct target of the event, we might have @@ -229,12 +229,12 @@ export function getInstanceFromNode(node: Node): Fiber | null { let inst: void | null | Fiber; if (enableInternalInstanceMap) { inst = - internalInstanceMap.get(((node: any): InstanceUnion)) || - (node: any)[internalContainerInstanceKey]; + internalInstanceMap.get(node as any as InstanceUnion) || + (node as any)[internalContainerInstanceKey]; } else { inst = - (node: any)[internalInstanceKey] || - (node: any)[internalContainerInstanceKey]; + (node as any)[internalInstanceKey] || + (node as any)[internalContainerInstanceKey]; } if (inst) { const tag = inst.tag; @@ -288,7 +288,7 @@ export function getFiberCurrentPropsFromNode( if (enableInternalInstanceMap) { return internalPropsMap.get(node) || null; } - return (node: any)[internalPropsKey] || null; + return (node as any)[internalPropsKey] || null; } export function updateFiberProps(node: Instance, props: Props): void { @@ -296,15 +296,15 @@ export function updateFiberProps(node: Instance, props: Props): void { internalPropsMap.set(node, props); return; } - (node: any)[internalPropsKey] = props; + (node as any)[internalPropsKey] = props; } export function getEventListenerSet(node: EventTarget): Set { - let elementListenerSet: Set | void = (node: any)[ + let elementListenerSet: Set | void = (node as any)[ internalEventHandlersKey ]; if (elementListenerSet === undefined) { - elementListenerSet = (node: any)[internalEventHandlersKey] = new Set(); + elementListenerSet = (node as any)[internalEventHandlersKey] = new Set(); } return elementListenerSet; } @@ -314,9 +314,9 @@ export function getFiberFromScopeInstance( ): null | Fiber { if (enableScopeAPI) { if (enableInternalInstanceMap) { - return internalInstanceMap.get(((scope: any): InstanceUnion)) || null; + return internalInstanceMap.get(scope as any as InstanceUnion) || null; } - return (scope: any)[internalInstanceKey] || null; + return (scope as any)[internalInstanceKey] || null; } return null; } @@ -325,22 +325,22 @@ export function setEventHandlerListeners( scope: EventTarget | ReactScopeInstance, listeners: Set, ): void { - (scope: any)[internalEventHandlerListenersKey] = listeners; + (scope as any)[internalEventHandlerListenersKey] = listeners; } export function getEventHandlerListeners( scope: EventTarget | ReactScopeInstance, ): null | Set { - return (scope: any)[internalEventHandlerListenersKey] || null; + return (scope as any)[internalEventHandlerListenersKey] || null; } export function addEventHandleToTarget( target: EventTarget | ReactScopeInstance, eventHandle: ReactDOMEventHandle, ): void { - let eventHandles = (target: any)[internalEventHandlesSetKey]; + let eventHandles = (target as any)[internalEventHandlesSetKey]; if (eventHandles === undefined) { - eventHandles = (target: any)[internalEventHandlesSetKey] = new Set(); + eventHandles = (target as any)[internalEventHandlesSetKey] = new Set(); } eventHandles.add(eventHandle); } @@ -349,7 +349,7 @@ export function doesTargetHaveEventHandle( target: EventTarget | ReactScopeInstance, eventHandle: ReactDOMEventHandle, ): boolean { - const eventHandles = (target: any)[internalEventHandlesSetKey]; + const eventHandles = (target as any)[internalEventHandlesSetKey]; if (eventHandles === undefined) { return false; } @@ -357,9 +357,9 @@ export function doesTargetHaveEventHandle( } export function getResourcesFromRoot(root: HoistableRoot): RootResources { - let resources = (root: any)[internalRootNodeResourcesKey]; + let resources = (root as any)[internalRootNodeResourcesKey]; if (!resources) { - resources = (root: any)[internalRootNodeResourcesKey] = { + resources = (root as any)[internalRootNodeResourcesKey] = { hoistableStyles: new Map(), hoistableScripts: new Map(), }; @@ -368,45 +368,45 @@ export function getResourcesFromRoot(root: HoistableRoot): RootResources { } export function isMarkedHoistable(node: Node): boolean { - return !!(node: any)[internalHoistableMarker]; + return !!(node as any)[internalHoistableMarker]; } export function markNodeAsHoistable(node: Node) { - (node: any)[internalHoistableMarker] = true; + (node as any)[internalHoistableMarker] = true; } export function getScrollEndTimer(node: EventTarget): ?TimeoutID { - return (node: any)[internalScrollTimer]; + return (node as any)[internalScrollTimer]; } export function setScrollEndTimer(node: EventTarget, timer: TimeoutID): void { - (node: any)[internalScrollTimer] = timer; + (node as any)[internalScrollTimer] = timer; } export function clearScrollEndTimer(node: EventTarget): void { - (node: any)[internalScrollTimer] = undefined; + (node as any)[internalScrollTimer] = undefined; } export function markNodeAsPendingLoad(node: Node): void { - (node: any)[internalLoadPendingKey] = true; + (node as any)[internalLoadPendingKey] = true; } export function clearPendingLoadOnNode(node: Node): void { - (node: any)[internalLoadPendingKey] = undefined; + (node as any)[internalLoadPendingKey] = undefined; } export function isNodePendingLoad(node: Node): boolean { - return (node: any)[internalLoadPendingKey] === true; + return (node as any)[internalLoadPendingKey] === true; } export function isOwnedInstance(node: Node): boolean { if (enableInternalInstanceMap) { return !!( - (node: any)[internalHoistableMarker] || - internalInstanceMap.has((node: any)) + (node as any)[internalHoistableMarker] || + internalInstanceMap.has(node as any) ); } return !!( - (node: any)[internalHoistableMarker] || (node: any)[internalInstanceKey] + (node as any)[internalHoistableMarker] || (node as any)[internalInstanceKey] ); } diff --git a/packages/react-dom-bindings/src/client/ReactDOMContainer.js b/packages/react-dom-bindings/src/client/ReactDOMContainer.js index df9bcfb44380..bc73db8a00e3 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMContainer.js +++ b/packages/react-dom-bindings/src/client/ReactDOMContainer.js @@ -24,6 +24,6 @@ export function isValidContainer(node: any): boolean { node.nodeType === DOCUMENT_FRAGMENT_NODE || (!disableCommentsAsDOMContainers && node.nodeType === COMMENT_NODE && - (node: any).nodeValue === ' react-mount-point-unstable ')) + (node as any).nodeValue === ' react-mount-point-unstable ')) ); } diff --git a/packages/react-dom-bindings/src/client/ReactDOMEventHandle.js b/packages/react-dom-bindings/src/client/ReactDOMEventHandle.js index 875a9c9697c3..abb66721c2d2 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMEventHandle.js +++ b/packages/react-dom-bindings/src/client/ReactDOMEventHandle.js @@ -35,11 +35,11 @@ type EventHandleOptions = { }; function isValidEventTarget(target: EventTarget | ReactScopeInstance): boolean { - return typeof (target: Object).addEventListener === 'function'; + return typeof (target as Object).addEventListener === 'function'; } function isReactScope(target: EventTarget | ReactScopeInstance): boolean { - return typeof (target: Object).getChildContextValues === 'function'; + return typeof (target as Object).getChildContextValues === 'function'; } function createEventHandleListener( @@ -59,12 +59,12 @@ function registerReactDOMEvent( domEventName: DOMEventName, isCapturePhaseListener: boolean, ): void { - if ((target: any).nodeType === ELEMENT_NODE) { + if ((target as any).nodeType === ELEMENT_NODE) { // Do nothing. We already attached all root listeners. } else if (enableScopeAPI && isReactScope(target)) { // Do nothing. We already attached all root listeners. } else if (isValidEventTarget(target)) { - const eventTarget = ((target: any): EventTarget); + const eventTarget = target as any as EventTarget; // These are valid event targets, but they are also // non-managed React nodes. listenToNativeEventForNonManagedEventTarget( @@ -85,7 +85,7 @@ export function createEventHandle( options?: EventHandleOptions, ): ReactDOMEventHandle { if (enableCreateEventHandleAPI) { - const domEventName = ((type: any): DOMEventName); + const domEventName = type as any as DOMEventName; // We cannot support arbitrary native events with eager root listeners // because the eager strategy relies on knowing the whole list ahead of time. @@ -137,7 +137,7 @@ export function createEventHandle( } targetListeners.add(listener); return () => { - ((targetListeners: any): Set).delete( + (targetListeners as any as Set).delete( listener, ); }; @@ -145,5 +145,5 @@ export function createEventHandle( return eventHandle; } - return (null: any); + return null as any; } diff --git a/packages/react-dom-bindings/src/client/ReactDOMInput.js b/packages/react-dom-bindings/src/client/ReactDOMInput.js index 0ae9824cb849..d38ae2fe0ae2 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMInput.js +++ b/packages/react-dom-bindings/src/client/ReactDOMInput.js @@ -96,7 +96,7 @@ export function updateInput( type: ?string, name: ?string, ) { - const node: HTMLInputElement = (element: any); + const node: HTMLInputElement = element as any; // Temporarily disconnect the input from any radio buttons. // Changing the type or name as the same time as changing the checked value @@ -126,7 +126,7 @@ export function updateInput( (value === 0 && node.value === '') || // We explicitly want to coerce to number here if possible. // eslint-disable-next-line - node.value != (value: any) + node.value != (value as any) ) { node.value = toString(getToStringValue(value)); } @@ -214,7 +214,7 @@ export function initInput( name: ?string, isHydrating: boolean, ) { - const node: HTMLInputElement = (element: any); + const node: HTMLInputElement = element as any; if ( type != null && @@ -235,7 +235,7 @@ export function initInput( // default value provided by the browser. See: #12872 if (isButton && (value === undefined || value === null)) { // We track the value just in case it changes type later on. - track((element: any)); + track(element as any); return; } @@ -342,7 +342,7 @@ export function initInput( } node.name = name; } - track((element: any)); + track(element as any); } export function hydrateInput( @@ -352,7 +352,7 @@ export function hydrateInput( checked: ?boolean, defaultChecked: ?boolean, ): void { - const node: HTMLInputElement = (element: any); + const node: HTMLInputElement = element as any; const defaultValueStr = defaultValue != null ? toString(getToStringValue(defaultValue)) : ''; @@ -370,7 +370,7 @@ export function hydrateInput( // Detach .checked from .defaultChecked but leave user input alone node.checked = node.checked; - const changed = trackHydrated((node: any), initialValue, initialChecked); + const changed = trackHydrated(node as any, initialValue, initialChecked); if (changed) { // If the current value is different, that suggests that the user // changed it before hydration. Queue a replay of the change event. @@ -382,7 +382,7 @@ export function hydrateInput( } export function restoreControlledInputState(element: Element, props: Object) { - const rootNode: HTMLInputElement = (element: any); + const rootNode: HTMLInputElement = element as any; updateInput( rootNode, props.value, @@ -398,7 +398,7 @@ export function restoreControlledInputState(element: Element, props: Object) { let queryRoot: Element = rootNode; while (queryRoot.parentNode) { - queryRoot = ((queryRoot.parentNode: any): Element); + queryRoot = queryRoot.parentNode as any as Element; } // If `rootNode.form` was non-null, then we could try `form.elements`, @@ -418,7 +418,7 @@ export function restoreControlledInputState(element: Element, props: Object) { ); for (let i = 0; i < group.length; i++) { - const otherNode = ((group[i]: any): HTMLInputElement); + const otherNode = group[i] as any as HTMLInputElement; if (otherNode === rootNode || otherNode.form !== rootNode.form) { continue; } @@ -453,7 +453,7 @@ export function restoreControlledInputState(element: Element, props: Object) { // If any updateInput() call set .checked to true, an input in this group // (often, `rootNode` itself) may have become unchecked for (let i = 0; i < group.length; i++) { - const otherNode = ((group[i]: any): HTMLInputElement); + const otherNode = group[i] as any as HTMLInputElement; if (otherNode.form !== rootNode.form) { continue; } diff --git a/packages/react-dom-bindings/src/client/ReactDOMSelect.js b/packages/react-dom-bindings/src/client/ReactDOMSelect.js index 00136aa8175b..6553016fcaee 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMSelect.js +++ b/packages/react-dom-bindings/src/client/ReactDOMSelect.js @@ -69,7 +69,7 @@ function updateOptions( const options: HTMLOptionsCollection = node.options; if (multiple) { - const selectedValues = (propValue: Array); + const selectedValues = propValue as Array; const selectedValue: {[string]: boolean} = {}; for (let i = 0; i < selectedValues.length; i++) { // Prefix to avoid chaos with special keys. @@ -149,7 +149,7 @@ export function initSelect( defaultValue: ?string, multiple: ?boolean, ) { - const node: HTMLSelectElement = (element: any); + const node: HTMLSelectElement = element as any; node.multiple = !!multiple; if (value != null) { updateOptions(node, !!multiple, value, false); @@ -164,7 +164,7 @@ export function hydrateSelect( defaultValue: ?string, multiple: ?boolean, ): void { - const node: HTMLSelectElement = (element: any); + const node: HTMLSelectElement = element as any; const options: HTMLOptionsCollection = node.options; const propValue: any = value != null ? value : defaultValue; @@ -172,7 +172,7 @@ export function hydrateSelect( let changed = false; if (multiple) { - const selectedValues = (propValue: ?Array); + const selectedValues = propValue as ?Array; const selectedValue: {[string]: boolean} = {}; if (selectedValues != null) { for (let i = 0; i < selectedValues.length; i++) { @@ -218,7 +218,7 @@ export function updateSelect( multiple: ?boolean, wasMultiple: ?boolean, ) { - const node: HTMLSelectElement = (element: any); + const node: HTMLSelectElement = element as any; if (value != null) { updateOptions(node, !!multiple, value, false); @@ -234,7 +234,7 @@ export function updateSelect( } export function restoreControlledSelectState(element: Element, props: Object) { - const node: HTMLSelectElement = (element: any); + const node: HTMLSelectElement = element as any; const value = props.value; if (value != null) { diff --git a/packages/react-dom-bindings/src/client/ReactDOMSrcObject.js b/packages/react-dom-bindings/src/client/ReactDOMSrcObject.js index 160d634236d2..f8c25ce5c358 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMSrcObject.js +++ b/packages/react-dom-bindings/src/client/ReactDOMSrcObject.js @@ -10,7 +10,7 @@ export function setSrcObject(domElement: Element, tag: string, value: any) { // We optimistically create the URL regardless of object type. This lets us // support cross-realms and any type that the browser supports like new types. - const url = URL.createObjectURL((value: any)); + const url = URL.createObjectURL(value as any); const loadEvent = tag === 'img' ? 'load' : 'loadstart'; const cleanUp = () => { // Once the object has started loading, then it's already collected by the diff --git a/packages/react-dom-bindings/src/client/ReactDOMTextarea.js b/packages/react-dom-bindings/src/client/ReactDOMTextarea.js index 75fe6b8fabce..be6b20806872 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMTextarea.js +++ b/packages/react-dom-bindings/src/client/ReactDOMTextarea.js @@ -66,7 +66,7 @@ export function updateTextarea( value: ?string, defaultValue: ?string, ) { - const node: HTMLTextAreaElement = (element: any); + const node: HTMLTextAreaElement = element as any; if (value != null) { // Cast `value` to a string to ensure the value is set correctly. While // browsers typically do this as necessary, jsdom doesn't. @@ -96,7 +96,7 @@ export function initTextarea( defaultValue: ?string, children: ?string, ) { - const node: HTMLTextAreaElement = (element: any); + const node: HTMLTextAreaElement = element as any; let initialValue = value; @@ -128,7 +128,7 @@ export function initTextarea( } const stringValue = getToStringValue(initialValue); - node.defaultValue = (stringValue: any); // This will be toString:ed. + node.defaultValue = stringValue as any; // This will be toString:ed. // This is in postMount because we need access to the DOM node, which is not // available until after the component has mounted. @@ -146,7 +146,7 @@ export function initTextarea( } } - track((element: any)); + track(element as any); } export function hydrateTextarea( @@ -154,7 +154,7 @@ export function hydrateTextarea( value: ?string, defaultValue: ?string, ): void { - const node: HTMLTextAreaElement = (element: any); + const node: HTMLTextAreaElement = element as any; let initialValue = value; if (initialValue == null) { if (defaultValue == null) { @@ -166,7 +166,7 @@ export function hydrateTextarea( // that any change event that fires will trigger onChange on the actual // current value. const stringValue = toString(getToStringValue(initialValue)); - const changed = trackHydrated((node: any), stringValue, false); + const changed = trackHydrated(node as any, stringValue, false); if (changed) { // If the current value is different, that suggests that the user // changed it before hydration. Queue a replay of the change event. diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js index f21c1b6154e6..d4e4dfde408c 100644 --- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js +++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js @@ -300,7 +300,7 @@ function getOwnerDocumentFromRootContainer( rootContainerElement: Element | Document | DocumentFragment, ): Document { return rootContainerElement.nodeType === DOCUMENT_NODE - ? (rootContainerElement: any) + ? (rootContainerElement as any) : rootContainerElement.ownerDocument; } @@ -314,7 +314,7 @@ export function getRootHostContext( case DOCUMENT_NODE: case DOCUMENT_FRAGMENT_NODE: { type = nodeType === DOCUMENT_NODE ? '#document' : '#fragment'; - const root = (rootContainerInstance: any).documentElement; + const root = (rootContainerInstance as any).documentElement; if (root) { const namespaceURI = root.namespaceURI; context = namespaceURI @@ -398,7 +398,7 @@ export function getChildHostContext( type: string, ): HostContext { if (__DEV__) { - const parentHostContextDev = ((parentHostContext: any): HostContextDev); + const parentHostContextDev = parentHostContext as any as HostContextDev; const context = getChildHostContextProd(parentHostContextDev.context, type); const ancestorInfo = updatedAncestorInfoDev( parentHostContextDev.ancestorInfo, @@ -406,7 +406,7 @@ export function getChildHostContext( ); return {context, ancestorInfo}; } - const parentNamespace = ((parentHostContext: any): HostContextProd); + const parentNamespace = parentHostContext as any as HostContextProd; return getChildHostContextProd(parentNamespace, type); } @@ -432,7 +432,7 @@ export function beforeActiveInstanceBlur(internalInstanceHandle: Object): void { if (enableCreateEventHandleAPI) { ReactBrowserEventEmitterSetEnabled(true); dispatchBeforeDetachedBlur( - (selectionInformation: any).focusedElem, + (selectionInformation as any).focusedElem, internalInstanceHandle, ); ReactBrowserEventEmitterSetEnabled(false); @@ -442,7 +442,7 @@ export function beforeActiveInstanceBlur(internalInstanceHandle: Object): void { export function afterActiveInstanceBlur(): void { if (enableCreateEventHandleAPI) { ReactBrowserEventEmitterSetEnabled(true); - dispatchAfterDetachedBlur((selectionInformation: any).focusedElem); + dispatchAfterDetachedBlur((selectionInformation as any).focusedElem); ReactBrowserEventEmitterSetEnabled(false); } } @@ -534,11 +534,11 @@ export function createInstance( let hostContextProd: HostContextProd; if (__DEV__) { // TODO: take namespace into account when validating. - const hostContextDev: HostContextDev = (hostContext: any); + const hostContextDev: HostContextDev = hostContext as any; validateDOMNesting(type, hostContextDev.ancestorInfo); hostContextProd = hostContextDev.context; } else { - hostContextProd = (hostContext: any); + hostContextProd = hostContext as any; } const ownerDocument = getOwnerDocumentFromRootContainer( @@ -586,7 +586,7 @@ export function createInstance( } div.innerHTML = '