diff --git a/flow-typed/environments/bom.js b/flow-typed/environments/bom.js index 7c082ea5dae0..3b297ee191ec 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 a1f5aa0eeff9..80b57161b9c0 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 56f60d3623c9..5d80c28d6231 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? @@ -601,7 +601,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); @@ -695,6 +695,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++; @@ -885,7 +886,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); } @@ -911,7 +912,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); } } @@ -990,7 +991,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; @@ -1021,6 +1022,7 @@ function customEncodeFormAction( ); } let boundPromise: Promise> = (referenceClosure.bound: any); + // $FlowFixMe[invalid-compare] if (boundPromise === null) { boundPromise = Promise.resolve([]); } @@ -1200,6 +1202,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 = @@ -1240,7 +1243,7 @@ function bind(this: Function): Function { const referenceClosure = knownServerReferences.get(this); if (!referenceClosure) { - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] return FunctionBind.apply(this, arguments); } @@ -1276,6 +1279,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 d7f857f7049e..5ba6e567d337 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 5623d507a3b7..b66d9281e2a0 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 66de8440b65e..26614fca9549 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, @@ -975,6 +975,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 1b25e3727023..7c67188bd811 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMComponent.js +++ b/packages/react-dom-bindings/src/client/ReactDOMComponent.js @@ -2119,6 +2119,7 @@ function hydrateAttribute( if (__DEV__) { checkAttributeStringCoercion(value, propKey); } + // $FlowFixMe[invalid-compare] if (serverValue === '' + value) { return; } @@ -2183,6 +2184,7 @@ function hydrateOverloadedBooleanAttribute( case 'symbol': return; default: + // $FlowFixMe[invalid-compare] if (value === false) { return; } @@ -2197,6 +2199,7 @@ function hydrateOverloadedBooleanAttribute( case 'symbol': break; case 'boolean': + // $FlowFixMe[invalid-compare] if (value === true && serverValue === '') { return; } @@ -2205,6 +2208,7 @@ function hydrateOverloadedBooleanAttribute( if (__DEV__) { checkAttributeStringCoercion(value, propKey); } + // $FlowFixMe[invalid-compare] if (serverValue === '' + value) { return; } @@ -2296,6 +2300,7 @@ function hydrateNumericAttribute( if (__DEV__) { checkAttributeStringCoercion(value, propKey); } + // $FlowFixMe[invalid-compare] if (serverValue === '' + value) { return; } @@ -2347,6 +2352,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 538dd4b70965..63ee2975480c 100644 --- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js +++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js @@ -1109,6 +1109,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 ) { @@ -1416,6 +1417,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 @@ -1522,7 +1524,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 @@ -1629,7 +1631,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', @@ -1666,7 +1668,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', @@ -1683,6 +1685,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', @@ -1779,11 +1782,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 @@ -1866,7 +1869,7 @@ export function cloneRootViewTransitionContainer( if (getComputedStyle(positionedAncestor).position !== 'static') { break; } - // $FlowFixMe: This is refined. + // $FlowFixMe[incompatible-type]: This is refined. positionedAncestor = positionedAncestor.parentNode; } @@ -2264,11 +2267,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 && @@ -2310,13 +2314,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 ( @@ -2331,7 +2335,7 @@ export function startViewTransition( const last = keyframes[keyframes.length - 1]; last.width = width; last.height = height; - // $FlowFixMe + // $FlowFixMe[incompatible-type] effect.setKeyframes(keyframes); } } @@ -2533,7 +2537,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. @@ -2555,7 +2559,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 @@ -2614,6 +2618,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. @@ -2623,7 +2628,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 ( @@ -2658,7 +2663,7 @@ export function startGestureTransition( continue; } const effect: KeyframeEffect = (anim.effect: any); - // $FlowFixMe + // $FlowFixMe[prop-missing] const pseudoElement: ?string = effect.pseudoElement; if ( pseudoElement != null && @@ -2718,7 +2723,7 @@ export function startGestureTransition( } animateGesture( effect.getKeyframes(), - // $FlowFixMe: Always documentElement atm. + // $FlowFixMe[incompatible-type]: Always documentElement atm. effect.target, pseudoElement, timeline, @@ -2746,7 +2751,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, @@ -2767,6 +2772,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, @@ -2889,6 +2895,7 @@ ViewTransitionPseudoElement.prototype.animate = function ( } : Object.assign( (// $FlowFixMe[prop-missing] + // $FlowFixMe[incompatible-type] {}: KeyframeAnimationOptions), options, ); @@ -2905,6 +2912,7 @@ ViewTransitionPseudoElement.prototype.getAnimations = function ( const selector = this._selector; const animations = scope.getAnimations( // $FlowFixMe[prop-missing] + // $FlowFixMe[incompatible-type] {subtree: true}, ); const result = []; @@ -3349,7 +3357,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; }; @@ -3473,6 +3481,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); @@ -4826,11 +4835,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; } @@ -5141,12 +5150,14 @@ function preinitStyle( } // Construct a Resource and cache it + // $FlowFixMe[incompatible-type] resource = { type: 'stylesheet', instance, count: 1, state, }; + // $FlowFixMe[incompatible-type] styles.set(key, resource); return; } diff --git a/packages/react-dom-bindings/src/client/estimateBandwidth.js b/packages/react-dom-bindings/src/client/estimateBandwidth.js index 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 73ce8d3dd29f..9d2f40dac3b2 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); @@ -3366,7 +3367,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)) { @@ -3562,6 +3563,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( @@ -4018,8 +4021,10 @@ function pushStartCustomElement( typeof propValue !== 'function' && typeof propValue !== 'symbol' ) { + // $FlowFixMe[invalid-compare] if (propValue === false) { continue; + // $FlowFixMe[invalid-compare] } else if (propValue === true) { propValue = ''; } else if (typeof propValue === 'object') { @@ -4611,6 +4616,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-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 a0b8eb98b486..ddd3b0f6833b 100644 --- a/packages/react-native-renderer/src/ReactFabricEventEmitter.js +++ b/packages/react-native-renderer/src/ReactFabricEventEmitter.js @@ -93,7 +93,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 533b20fa6d74..c595aef3d2ec 100644 --- a/packages/react-native-renderer/src/ReactFiberConfigFabric.js +++ b/packages/react-native-renderer/src/ReactFiberConfigFabric.js @@ -153,6 +153,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 @@ -402,6 +403,7 @@ export function resolveUpdatePriority(): EventPriority { return currentUpdatePriority; } + // $FlowFixMe[constant-condition] const currentEventPriority = fabricGetCurrentEventPriority ? fabricGetCurrentEventPriority() : null; @@ -711,8 +713,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; } @@ -735,8 +738,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; } @@ -899,8 +903,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 cbe70a0d88f8..607ba71f7bd0 100644 --- a/packages/react-native-renderer/src/ReactFiberConfigFabricWithViewTransition.js +++ b/packages/react-native-renderer/src/ReactFiberConfigFabricWithViewTransition.js @@ -90,7 +90,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/ReactFiberConfigNative.js b/packages/react-native-renderer/src/ReactFiberConfigNative.js index 404ae7a54a85..41e47faea51b 100644 --- a/packages/react-native-renderer/src/ReactFiberConfigNative.js +++ b/packages/react-native-renderer/src/ReactFiberConfigNative.js @@ -308,7 +308,7 @@ export function getPublicInstance(instance: Instance): PublicInstance { } // $FlowExpectedError[prop-missing] - // $FlowExpectedError[incompatible-return] + // $FlowExpectedError[incompatible-type] return instance.canonical.publicInstance; } diff --git a/packages/react-native-renderer/src/ReactNativeEventEmitter.js b/packages/react-native-renderer/src/ReactNativeEventEmitter.js index 270708036748..a79c6335aef6 100644 --- a/packages/react-native-renderer/src/ReactNativeEventEmitter.js +++ b/packages/react-native-renderer/src/ReactNativeEventEmitter.js @@ -235,7 +235,7 @@ export function receiveTouches( rootNodeID = target; } } - // $FlowFixMe[incompatible-call] Shouldn't we *not* call it if rootNodeID is null? + // $FlowFixMe[incompatible-type] Shouldn't we *not* call it if rootNodeID is null? _receiveRootNodeIDEvent(rootNodeID, eventTopLevelType, nativeEvent); } } diff --git a/packages/react-native-renderer/src/ReactNativeFiberInspector.js b/packages/react-native-renderer/src/ReactNativeFiberInspector.js index e8be83f9a9f4..15fd5a12089f 100644 --- a/packages/react-native-renderer/src/ReactNativeFiberInspector.js +++ b/packages/react-native-renderer/src/ReactNativeFiberInspector.js @@ -236,7 +236,7 @@ function getInspectorDataForViewAtPoint( pointerY: locationY, frame: {left, top, width, height}, touchedViewTag: nativeViewTag, - // $FlowExpectedError[incompatible-call] + // $FlowExpectedError[incompatible-type] closestPublicInstance: nativeViewTag, }); }, diff --git a/packages/react-native-renderer/src/ReactNativePublicCompat.js b/packages/react-native-renderer/src/ReactNativePublicCompat.js index e0193ddc37e0..ad58ce95eb14 100644 --- a/packages/react-native-renderer/src/ReactNativePublicCompat.js +++ b/packages/react-native-renderer/src/ReactNativePublicCompat.js @@ -61,14 +61,14 @@ 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; } // For compatibility with legacy renderer instances if (componentOrHandle._nativeTag) { // $FlowFixMe[incompatible-exact] Necessary when running Flow on Fabric - // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] return componentOrHandle; } @@ -84,7 +84,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; } @@ -146,16 +146,16 @@ 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; } if (hostInstance._nativeTag != null) { - // $FlowFixMe[incompatible-return] For compatibility with legacy renderer instances + // $FlowFixMe[incompatible-type] For compatibility with legacy renderer instances return hostInstance._nativeTag; } - // $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); } @@ -214,9 +214,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/ReactNativeRenderer.js b/packages/react-native-renderer/src/ReactNativeRenderer.js index c7f7a11dcc57..da6d08feecce 100644 --- a/packages/react-native-renderer/src/ReactNativeRenderer.js +++ b/packages/react-native-renderer/src/ReactNativeRenderer.js @@ -170,6 +170,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/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 cf2c08236733..1da1d53ad6cd 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.js @@ -1837,6 +1837,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. @@ -1986,6 +1987,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 { @@ -2120,8 +2122,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__) { @@ -2135,6 +2139,7 @@ function mountLazyComponent( props, renderLanes, ); + // $FlowFixMe[invalid-compare] } else if ($$typeof === REACT_MEMO_TYPE) { workInProgress.tag = MemoComponent; return updateMemoComponent( @@ -2144,6 +2149,7 @@ function mountLazyComponent( props, renderLanes, ); + // $FlowFixMe[invalid-compare] } else if ($$typeof === REACT_CONTEXT_TYPE) { workInProgress.tag = ContextProvider; workInProgress.type = Component; @@ -2154,8 +2160,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?'; @@ -2272,6 +2280,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; @@ -2310,6 +2319,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". @@ -3254,9 +3264,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 . ' + @@ -3266,7 +3280,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 . ' + @@ -3826,6 +3842,7 @@ function remountFiber( newWorkInProgress.return = oldWorkInProgress.return; newWorkInProgress.ref = oldWorkInProgress.ref; + // $FlowFixMe[constant-condition] if (__DEV__) { newWorkInProgress._debugInfo = oldWorkInProgress._debugInfo; } @@ -4293,11 +4310,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 05aeb3cfbb37..a782c89016d1 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 643be63ffa1c..84c6a93cecae 100644 --- a/packages/react-reconciler/src/ReactFiberThenable.js +++ b/packages/react-reconciler/src/ReactFiberThenable.js @@ -290,6 +290,7 @@ export function suspendCommit(): void { // This extra indirection only exists so it can handle passing // noopSuspenseyCommitThenable through to throwException. // TODO: Factor the thenable check out of throwException + // $FlowFixMe[incompatible-type] suspendedThenable = noopSuspenseyCommitThenable; throw SuspenseyCommitException; } diff --git a/packages/react-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 9a3953c1b5a2..333eb3a25597 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js @@ -1320,7 +1320,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 @@ -3041,7 +3043,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); } @@ -3051,7 +3053,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); } } @@ -4370,6 +4372,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 a4bda173f158..3b17e88f1ebc 100644 --- a/packages/react-server-dom-esm/src/server/ReactFlightDOMServerNode.js +++ b/packages/react-server-dom-esm/src/server/ReactFlightDOMServerNode.js @@ -123,11 +123,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); @@ -398,7 +398,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 d267edd085af..989e62d751d5 100644 --- a/packages/react-server-dom-parcel/src/server/ReactFlightDOMServerNode.js +++ b/packages/react-server-dom-parcel/src/server/ReactFlightDOMServerNode.js @@ -136,11 +136,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); @@ -385,6 +385,7 @@ export function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); debugStream.pipeTo(debugChannelWritable); @@ -409,6 +410,7 @@ export function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); return stream; @@ -519,6 +521,7 @@ export function prerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); resolve({prelude: stream}); @@ -628,7 +631,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, ); }); @@ -698,7 +701,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 5381072b3ad8..e803200a8c4c 100644 --- a/packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerNode.js +++ b/packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerNode.js @@ -129,11 +129,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); @@ -380,6 +380,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); debugStream.pipeTo(debugChannelWritable); @@ -404,6 +405,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); return stream; @@ -516,6 +518,7 @@ function prerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); resolve({prelude: stream}); @@ -620,7 +623,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, ); }); @@ -692,7 +695,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 f118d764447f..84b1a3d2a936 100644 --- a/packages/react-server-dom-unbundled/src/server/ReactFlightDOMServerNode.js +++ b/packages/react-server-dom-unbundled/src/server/ReactFlightDOMServerNode.js @@ -129,11 +129,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); @@ -380,6 +380,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); debugStream.pipeTo(debugChannelWritable); @@ -404,6 +405,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); return stream; @@ -516,6 +518,7 @@ function prerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); resolve({prelude: stream}); @@ -620,7 +623,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, ); }); @@ -692,7 +695,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 e710eafd00a1..c0aac7e28e4b 100644 --- a/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerNode.js +++ b/packages/react-server-dom-webpack/src/server/ReactFlightDOMServerNode.js @@ -129,11 +129,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); @@ -380,6 +380,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); debugStream.pipeTo(debugChannelWritable); @@ -404,6 +405,7 @@ function renderToReadableStream( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); return stream; @@ -516,6 +518,7 @@ function prerender( }, }, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. + // $FlowFixMe[incompatible-type] {highWaterMark: 0}, ); resolve({prelude: stream}); @@ -621,6 +624,7 @@ function decodeReplyFromBusboy( reportGlobalError( response, // $FlowFixMe[incompatible-call] types Error and mixed are incompatible + // $FlowFixMe[incompatible-type] err, ); }); @@ -692,7 +696,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 0b115199fc3b..4de1f05061fa 100644 --- a/packages/react-server/src/ReactFizzServer.js +++ b/packages/react-server/src/ReactFizzServer.js @@ -780,6 +780,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; @@ -1363,7 +1364,7 @@ function renderSuspenseBoundary( } return; } - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. const task: RenderTask = someTask; const prevKeyPath = task.keyPath; @@ -2175,11 +2176,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) { @@ -2316,7 +2318,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 @@ -2817,6 +2819,7 @@ function renderLazyComponent( request.status === ABORTING && // We're going to discard this render anyway. // We just need to reach the point where we suspended in dev. + // $FlowFixMe[invalid-compare] (!__DEV__ || request.status !== STALLED_DEV) ) { // eslint-disable-next-line no-throw-literal @@ -2946,9 +2949,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; @@ -2956,14 +2963,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); @@ -2971,6 +2981,7 @@ function renderElement( } // Fallthrough } + // $FlowFixMe[invalid-compare] case REACT_SCOPE_TYPE: { if (enableScopeAPI) { const prevKeyPath = task.keyPath; @@ -2981,33 +2992,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; @@ -3020,6 +3038,7 @@ function renderElement( if ( type === undefined || (typeof type === 'object' && + // $FlowFixMe[invalid-compare] type !== null && Object.keys(type).length === 0) ) { @@ -3505,11 +3524,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) { @@ -3799,7 +3819,7 @@ function renderChildrenArray( if (task.replay !== null) { replayFragment( request, - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. task, children, childIndex, @@ -3939,6 +3959,7 @@ function trackPostpone( return; } + // $FlowFixMe[invalid-compare] if (boundary !== null && boundary.status === PENDING) { const boundaryNode = trackPostponedBoundary( request, @@ -3970,6 +3991,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. @@ -4182,6 +4204,7 @@ function renderNode( if (request.status === ABORTING) { // We are aborting so we can just bubble up to the task by falling through + // $FlowFixMe[invalid-compare] } else if (typeof x === 'object' && x !== null) { // $FlowFixMe[method-unbinding] if (typeof x.then === 'function') { @@ -4192,7 +4215,7 @@ function renderNode( : null; const newTask = spawnNewSuspendedReplayTask( request, - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. task, thenableState, ); @@ -4228,7 +4251,7 @@ function renderNode( : null; const newTask = spawnNewSuspendedReplayTask( request, - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. task, thenableState, ); @@ -4283,6 +4306,7 @@ function renderNode( if (request.status === ABORTING) { // We are aborting so we can just bubble up to the task by falling through + // $FlowFixMe[invalid-compare] } else if (typeof x === 'object' && x !== null) { // $FlowFixMe[method-unbinding] if (typeof x.then === 'function') { @@ -4293,7 +4317,7 @@ function renderNode( : null; const newTask = spawnNewSuspendedRenderTask( request, - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. task, thenableState, ); @@ -4328,7 +4352,7 @@ function renderNode( : null; const newTask = spawnNewSuspendedRenderTask( request, - // $FlowFixMe: Refined. + // $FlowFixMe[incompatible-type]: Refined. task, thenableState, ); @@ -4623,7 +4647,9 @@ function abortTask(task: Task, request: Request, error: mixed): void { node !== null && (isArray(node) || typeof node[ASYNC_ITERATOR] === 'function' || + // $FlowFixMe[invalid-compare] node.$$typeof === REACT_ELEMENT_TYPE || + // $FlowFixMe[invalid-compare] node.$$typeof === REACT_LAZY_TYPE) && isArray(node._debugInfo) ) { @@ -4874,6 +4900,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; @@ -5030,13 +5057,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, ); @@ -5206,6 +5233,7 @@ function retryReplayTask(request: Request, task: ReplayTask): void { getSuspendedThenable() : thrownValue; + // $FlowFixMe[invalid-compare] if (typeof x === 'object' && x !== null) { // $FlowFixMe[method-unbinding] if (typeof x.then === 'function') { @@ -6012,6 +6040,7 @@ function flushCompletedQueues( export function startWork(request: Request): void { request.flushScheduled = request.destination !== null; // When prerendering we use microtasks for pinging work + // $FlowFixMe[constant-condition] if (supportsRequestStorage) { scheduleMicrotask(() => requestStorage.run(request, performWork, request)); } else { @@ -6032,6 +6061,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 6849f16e397d..f97edc0ef0fb 100644 --- a/packages/react-server/src/ReactFizzThenable.js +++ b/packages/react-server/src/ReactFizzThenable.js @@ -259,7 +259,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; 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 5f58e918f3e8..0dfbc18a302f 100644 --- a/packages/react-server/src/ReactFlightReplyServer.js +++ b/packages/react-server/src/ReactFlightReplyServer.js @@ -140,6 +140,7 @@ ReactPromise.prototype.then = function ( while (inspectedValue instanceof ReactPromise) { cycleProtection++; if ( + // $FlowFixMe[invalid-compare] inspectedValue === chunk || visited.has(inspectedValue) || cycleProtection > 1000 @@ -150,6 +151,7 @@ ReactPromise.prototype.then = function ( return; } visited.add(inspectedValue); + // $FlowFixMe[invalid-compare] if (inspectedValue.status === INITIALIZED) { inspectedValue = inspectedValue.value; } else { @@ -290,7 +292,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; } @@ -788,7 +790,7 @@ export function reportGlobalError(response: Response, error: Error): void { triggerErrorOnChunk(response, chunk, error); } else if (chunk.status === INITIALIZED && chunk.reason !== null) { const maybeController = chunk.reason; - // $FlowFixMe + // $FlowFixMe[prop-missing] if (typeof maybeController.error === 'function') { maybeController.error(error); } @@ -1388,7 +1390,7 @@ function parseReadableStream( } closed = true; if (previousBlockedChunk === null) { - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] controller.error(error); } else { const blockedChunk = previousBlockedChunk; @@ -1611,7 +1613,7 @@ function parseModelString( const entries = backingFormData.getAll(entryKey); const newKey = entryKey.slice(formPrefix.length); for (let j = 0; j < entries.length; j++) { - // $FlowFixMe[incompatible-call] + // $FlowFixMe[incompatible-type] data.append(newKey, entries[j]); } // These entries have now all been consumed. Let's free it. diff --git a/packages/react-server/src/ReactFlightServer.js b/packages/react-server/src/ReactFlightServer.js index 7f6376821b9b..ab63218080a5 100644 --- a/packages/react-server/src/ReactFlightServer.js +++ b/packages/react-server/src/ReactFlightServer.js @@ -392,7 +392,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', ); @@ -421,6 +421,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) { @@ -437,6 +438,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'); @@ -849,6 +851,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; @@ -1149,7 +1152,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 { @@ -1227,7 +1230,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() { @@ -1246,7 +1250,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); } @@ -1360,7 +1364,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); } } @@ -1382,7 +1386,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); } } @@ -1582,10 +1586,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) { @@ -1622,10 +1626,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) { @@ -1725,6 +1729,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) { @@ -1768,6 +1773,7 @@ function renderFunctionComponent( if (request.status === ABORTING) { if ( typeof result === 'object' && + // $FlowFixMe[invalid-compare] result !== null && typeof result.then === 'function' && !isClientReference(result) @@ -1873,6 +1879,7 @@ function warnForMissingKey( ); }; + // $FlowFixMe[constant-condition] if (supportsComponentStorage) { // Run the component in an Async Context that tracks the current owner. if (debugTask) { @@ -3053,6 +3060,7 @@ function serializeServerReference( request.bundlerConfig, serverReference, ); + // $FlowFixMe[constant-condition] if (error) { const frames = parseStackTrace(error, 1); if (frames.length > 0) { @@ -3246,17 +3254,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); } @@ -3294,7 +3302,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) { @@ -3304,7 +3312,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() { @@ -3323,13 +3332,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); @@ -3397,6 +3406,7 @@ function renderModel( getSuspendedThenable() : thrownValue; + // $FlowFixMe[invalid-compare] if (typeof x === 'object' && x !== null) { // $FlowFixMe[method-unbinding] if (typeof x.then === 'function') { @@ -3924,7 +3934,7 @@ function renderModelDestructive( } } - // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] return value; } @@ -3945,6 +3955,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 @@ -4089,6 +4100,7 @@ function logRecoverableError( try { const onError = request.onError; if (__DEV__ && task !== null) { + // $FlowFixMe[constant-condition] if (supportsRequestStorage) { errorDigest = requestStorage.run( undefined, @@ -4101,6 +4113,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); @@ -4704,6 +4717,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( @@ -5110,7 +5124,7 @@ function renderDebugModel( return instanceDescription; } - // $FlowFixMe[incompatible-return] + // $FlowFixMe[incompatible-type] return value; } @@ -5251,6 +5265,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 @@ -5314,10 +5329,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); @@ -5668,6 +5683,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); @@ -5886,6 +5902,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') { @@ -6164,6 +6181,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 303fed599cdc..709374492ef4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8167,6 +8167,7 @@ eslint-plugin-no-unsanitized@4.0.2: "eslint-plugin-react-internal@link:./scripts/eslint-rules": version "0.0.0" + uid "" eslint-plugin-react@^6.7.1: version "6.10.3" @@ -9239,17 +9240,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" @@ -10131,22 +10132,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" @@ -10155,6 +10149,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"