[flow] Bump flow to v0.307.1 (#36199)

## Summary

Notable changes:
- Only $FlowFixMe, $FlowExpectedError suppression comments are supported
- All suppression comments need error code
- A lot of new invalid-compare and constant-condition errors suppressed.
These errors reveal potential logical bugs

## How did you test this change?

`yarn flow-ci`
This commit is contained in:
Sam Zhou
2026-06-05 13:54:38 -04:00
committed by GitHub
parent 384e36ba10
commit 78cf315a48
197 changed files with 977 additions and 321 deletions
+1
View File
@@ -874,6 +874,7 @@ declare class SharedWorker extends EventTarget {
declare function importScripts(...urls: Array<string | TrustedScriptURL>): void;
declare class WorkerGlobalScope extends EventTarget {
// $FlowFixMe[incompatible-variance]
self: this;
location: WorkerLocation;
navigator: WorkerNavigator;
+1
View File
@@ -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;
}
+3
View File
@@ -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<SocketT>, ...};
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<http$ClientRequest<SocketT>>, ...};
// $FlowFixMe[incompatible-variance]
sockets: {[name: string]: $ReadOnlyArray<SocketT>, ...};
}
+1 -1
View File
@@ -42,7 +42,7 @@ declare class ReadableStreamReader {
closed: boolean;
cancel(reason: string): void;
cancel(reason: string): Promise<void>;
read(): Promise<{
value: ?any,
done: boolean,
+2 -2
View File
@@ -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",
+2 -2
View File
@@ -163,7 +163,7 @@ export async function act<T>(scope: () => Thenable<T>): Thenable<T> {
throw thrownError;
}
// $FlowFixMe[incompatible-return]
// $FlowFixMe[incompatible-type]
return result;
} finally {
const depth = actingUpdatesScopeDepth;
@@ -285,7 +285,7 @@ export async function serverAct<T>(scope: () => Thenable<T>): Thenable<T> {
throw thrownError;
}
// $FlowFixMe[incompatible-return]
// $FlowFixMe[incompatible-type]
return result;
} finally {
if (typeof process === 'object') {
+1
View File
@@ -115,6 +115,7 @@ export function createLRU<T>(limit: number): LRU<T> {
function access(entry: Entry<T>): T {
const next = entry.next;
// $FlowFixMe[invalid-compare]
if (next !== null) {
// Entry already cached
const resolvedFirst: Entry<T> = (first: any);
@@ -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
}
+3 -2
View File
@@ -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
}
@@ -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
}
+14 -11
View File
@@ -281,12 +281,12 @@ ReactPromise.prototype.then = function <T>(
const rejectCallback = reject;
const wrapperPromise: Promise<T> = 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<T>(
// a stream chunk since any other row shouldn't have more than one entry.
const streamChunk: InitializedStreamChunk<any> = (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<T>(
}
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);
@@ -21,6 +21,7 @@ export function readPartialStringChunk(
decoder: StringDecoder,
buffer: Uint8Array,
): string {
// $FlowFixMe[incompatible-type]
return decoder.decode(buffer, decoderOptions);
}
+10 -6
View File
@@ -584,7 +584,7 @@ export function processReply(
}
if (isArray(value)) {
// $FlowFixMe[incompatible-return]
// $FlowFixMe[incompatible-type]
return value;
}
// TODO: Should we the Object.prototype.toString.call() to test for cross-realm objects?
@@ -603,7 +603,7 @@ export function processReply(
const prefix = formFieldPrefix + '_' + refId + '_';
// $FlowFixMe[prop-missing]: FormData has forEach.
value.forEach((originalValue: string | File, originalKey: string) => {
// $FlowFixMe[incompatible-call]
// $FlowFixMe[incompatible-type]
data.append(prefix + originalKey, originalValue);
});
return serializeFormDataReference(refId);
@@ -697,6 +697,7 @@ export function processReply(
const iteratorFn = getIteratorFn(value);
if (iteratorFn) {
const iterator = iteratorFn.call(value);
// $FlowFixMe[invalid-compare]
if (iterator === value) {
// Iterator, not Iterable
const iteratorId = nextPartId++;
@@ -887,7 +888,7 @@ export function processReply(
}
}
modelRoot = model;
// $FlowFixMe[incompatible-return] it's not going to be undefined because we'll encode it.
// $FlowFixMe[incompatible-type] it's not going to be undefined because we'll encode it.
return JSON.stringify(model, resolveToJSON);
}
@@ -913,7 +914,7 @@ export function processReply(
// Otherwise, we use FormData to let us stream in the result.
formData.set(formFieldPrefix + '0', json);
if (pendingParts === 0) {
// $FlowFixMe[incompatible-call] this has already been refined.
// $FlowFixMe[incompatible-type] this has already been refined.
resolve(formData);
}
}
@@ -992,7 +993,7 @@ function defaultEncodeFormAction(
const prefixedData = new FormData();
// $FlowFixMe[prop-missing]
encodedFormData.forEach((value: string | File, key: string) => {
// $FlowFixMe[incompatible-call]
// $FlowFixMe[incompatible-type]
prefixedData.append('$ACTION_' + identifierPrefix + ':' + key, value);
});
data = prefixedData;
@@ -1023,6 +1024,7 @@ function customEncodeFormAction(
);
}
let boundPromise: Promise<Array<any>> = (referenceClosure.bound: any);
// $FlowFixMe[invalid-compare]
if (boundPromise === null) {
boundPromise = Promise.resolve([]);
}
@@ -1202,6 +1204,7 @@ export function registerBoundServerReference<T: 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 in the browser.
const $$FORM_ACTION =
@@ -1242,7 +1245,7 @@ function bind(this: Function): Function {
const referenceClosure = knownServerReferences.get(this);
if (!referenceClosure) {
// $FlowFixMe[incompatible-call]
// $FlowFixMe[incompatible-type]
return FunctionBind.apply(this, arguments);
}
@@ -1278,6 +1281,7 @@ function bind(this: Function): Function {
// Expose encoder for use by SSR, as well as a special bind that can be used to
// keep server capabilities.
// $FlowFixMe[constant-condition]
if (usedWithSSR) {
// Only expose this in builds that would actually use it. Not needed on the client.
Object.defineProperties((newFn: any), {
+5 -1
View File
@@ -200,6 +200,7 @@ const SuspenseException: mixed = new Error(
);
function use<T>(usable: Usable<T>): T {
// $FlowFixMe[invalid-compare]
if (usable !== null && typeof usable === 'object') {
// $FlowFixMe[method-unbinding]
if (typeof usable.then === 'function') {
@@ -729,8 +730,9 @@ function useActionState<S, P>(
function useHostTransitionStatus(): TransitionStatus {
const status = readContext<TransitionStatus>(
// $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<TransitionStatus>),
);
@@ -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;
+9 -2
View File
@@ -51,6 +51,7 @@ let savedComponentFilters: Array<ComponentFilter> =
getDefaultComponentFilters();
function debug(methodName: string, ...args: Array<mixed>) {
// $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<any>) {
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);
}
+3 -1
View File
@@ -83,6 +83,7 @@ log.error = (...args: Array<mixed>) =>
console.error('[React DevTools]', ...args);
function debug(methodName: string, ...args: Array<mixed>) {
// $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,
+1 -1
View File
@@ -94,7 +94,7 @@ chrome.runtime.onConnect.addListener(port => {
registerTab(tabId);
registerProxyPort(
port,
// $FlowFixMe[incompatible-call]
// $FlowFixMe[incompatible-type]
tabId,
);
@@ -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, {
+1
View File
@@ -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;
+1
View File
@@ -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() {
@@ -48,11 +48,13 @@ export async function withAsyncPerfMeasurements<TReturn>(
onComplete?: number => void,
): Promise<TReturn> {
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<TReturn>(
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<TReturn>(
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);
}
+3
View File
@@ -46,6 +46,7 @@ import {
} from '../storage';
const debug = (methodName: string, ...args: Array<string>) => {
// $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<number>) => void = operations => {
// $FlowFixMe[constant-condition]
if (__DEBUG__) {
debug(
'onHookOperations',
@@ -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 <link> 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 <link> 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;
}
@@ -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';
@@ -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);
}
@@ -32,6 +32,7 @@ export default function formatWithStyles(
): $ReadOnlyArray<any> {
if (
inputArgs === undefined ||
// $FlowFixMe[invalid-compare]
inputArgs === null ||
inputArgs.length === 0 ||
// Matches any of %c but not %%c
+1 -1
View File
@@ -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) {
@@ -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;
@@ -104,6 +104,7 @@ export function getNestedBoundingClientRect(
}
// $FlowFixMe[incompatible-variance]
// $FlowFixMe[incompatible-type]
return mergeRectOffsets(rects);
} else {
// $FlowFixMe[incompatible-variance]
+2 -2
View File
@@ -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);
@@ -26,6 +26,7 @@ export type ContextMenuHandle = {
};
export type ContextMenuComponent = component(
ref: React$RefSetter<ContextMenuHandle>,
// eslint-disable-next-line no-undef
ref: React.RefSetter<ContextMenuHandle>,
);
export type ContextMenuRef = {current: ContextMenuHandle | null};
+18
View File
@@ -96,6 +96,7 @@ class RectRBush extends RBush<Rect> {
}
const debug = (methodName: string, ...args: Array<string>) => {
// $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<SuspenseTimelineStep> {
const target: Array<SuspenseTimelineStep> = [];
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<number>) => 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');
}
@@ -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);
}
@@ -70,13 +70,16 @@ export default function InspectedElementContextTree({
<div className={styles.Header}>
{hasLegacyContext ? 'legacy context' : 'context'}
</div>
{/* $FlowFixMe[constant-condition] */}
{!isEmpty && (
<Button onClick={handleCopy} title="Copy to clipboard">
<ButtonIcon type="copy" />
</Button>
)}
</div>
{/* $FlowFixMe[constant-condition] */}
{isEmpty && <div className={styles.Empty}>None</div>}
{/* $FlowFixMe[constant-condition] */}
{!isEmpty &&
(entries: any).map(([name, value]) => (
<KeyValue
@@ -58,13 +58,16 @@ export default function InspectedElementStateTree({
<div>
<div className={styles.HeaderRow}>
<div className={styles.Header}>state</div>
{/* $FlowFixMe[constant-condition] */}
{!isEmpty && (
<Button onClick={handleCopy} title="Copy to clipboard">
<ButtonIcon type="copy" />
</Button>
)}
</div>
{/* $FlowFixMe[constant-condition] */}
{isEmpty && <div className={styles.Empty}>None</div>}
{/* $FlowFixMe[constant-condition] */}
{!isEmpty &&
(entries: any).map(([name, value]) => (
<KeyValue
@@ -558,6 +558,7 @@ export default function KeyValue({
}
}
// $FlowFixMe[incompatible-type]
return children;
}
@@ -57,7 +57,7 @@ const resource: Resource<
resolveFn = resolve;
});
// $FlowFixMe[incompatible-call] found when upgrading Flow
// $FlowFixMe[incompatible-type] found when upgrading Flow
inProgressRequests.set(element, {promise, resolveFn});
return (promise: $FlowFixMe);
@@ -93,7 +93,7 @@ function useChangeOwnerAction(): (nextOwnerID: number) => void {
resolveFn = resolve;
});
// $FlowFixMe[incompatible-call] found when upgrading Flow
// $FlowFixMe[incompatible-type] found when upgrading Flow
inProgressRequests.set(element, {promise, resolveFn});
}
@@ -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'});
}
@@ -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;
@@ -37,6 +37,7 @@ import type {
} from 'react-devtools-shared/src/devtools/views/Profiler/types';
const debug = (methodName: string, ...args: Array<string>) => {
// $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})`,
@@ -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;
@@ -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 =
@@ -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 {
@@ -189,6 +189,7 @@ function SuspenseBreadcrumbsMenu({
)}
onPointerLeave={onItemPointerLeave}
type="button">
{/* $FlowFixMe[invalid-compare] */}
{selectedSuspenseNode === null
? 'Unknown'
: selectedSuspenseNode.name || 'Unknown'}
@@ -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;
@@ -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 =
+1 -1
View File
@@ -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)
@@ -52,6 +52,7 @@ function readRecord<T>(record: Thenable<T>): 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()`,
+1 -1
View File
@@ -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]);
}
}
+4
View File
@@ -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()');
}
@@ -128,6 +128,7 @@ function extractAndLoadSourceMapJSON(
// Deduplicate fetches, since there can be multiple location keys per source map.
const dedupedFetchPromises = new Map<string, Promise<$FlowFixMe>>();
// $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<string> {
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}"`,
@@ -82,6 +82,7 @@ const originalURLToMetadataCache: LRUCache<string, CachedSourceCodeMetadata> =
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}"`,
@@ -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};
+2 -1
View File
@@ -597,7 +597,7 @@ export function parseElementDisplayNameFromBackend(
}
return {
// $FlowFixMe[incompatible-return]
// $FlowFixMe[incompatible-type]
formattedDisplayName: displayName,
hocDisplayNames,
compiledWithForget: false,
@@ -976,6 +976,7 @@ export function formatDataForPreview(
case 'html_element':
return `<${truncateForDisplay(data.tagName.toLowerCase())} />`;
case 'function':
// $FlowFixMe[invalid-compare]
if (typeof data.name === 'function' || data.name === '') {
return '() => {}';
}
+2
View File
@@ -28,6 +28,7 @@ function Frame(props) {
React.useLayoutEffect(function () {
const iframe = ref.current;
// $FlowFixMe[constant-condition]
if (iframe) {
const html = `
<!DOCTYPE html>
@@ -57,6 +58,7 @@ function Frame(props) {
style={iframeStyle}
/>
{/* $FlowFixMe[constant-condition] */}
{element ? createPortal(props.children, element) : null}
</Fragment>
);
@@ -72,7 +72,7 @@ function useDeepHookF() {
const ContextA = createContext('A');
const ContextB = createContext('B');
function FunctionWithHooks(props: any, ref: React$RefSetter<any>) {
function FunctionWithHooks(props: any, ref: React.RefSetter<any>) {
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>) => any,
Component: (props: any, ref: React.RefSetter<any>) => any,
) {
function Hoc() {
return <Component />;
+1 -1
View File
@@ -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));
}
+1
View File
@@ -438,6 +438,7 @@ function AutoSizedCanvas({
if (suspenseEventsViewWrapper !== null) {
rootView.addSubview(suspenseEventsViewWrapper);
}
// $FlowFixMe[invalid-compare]
if (reactMeasuresViewWrapper !== null) {
rootView.addSubview(reactMeasuresViewWrapper);
}
@@ -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,
@@ -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;
@@ -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);
}
}
@@ -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,
@@ -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;
}
@@ -2120,6 +2120,7 @@ function hydrateAttribute(
if (__DEV__) {
checkAttributeStringCoercion(value, propKey);
}
// $FlowFixMe[invalid-compare]
if (serverValue === '' + value) {
return;
}
@@ -2184,6 +2185,7 @@ function hydrateOverloadedBooleanAttribute(
case 'symbol':
return;
default:
// $FlowFixMe[invalid-compare]
if (value === false) {
return;
}
@@ -2198,6 +2200,7 @@ function hydrateOverloadedBooleanAttribute(
case 'symbol':
break;
case 'boolean':
// $FlowFixMe[invalid-compare]
if (value === true && serverValue === '') {
return;
}
@@ -2206,6 +2209,7 @@ function hydrateOverloadedBooleanAttribute(
if (__DEV__) {
checkAttributeStringCoercion(value, propKey);
}
// $FlowFixMe[invalid-compare]
if (serverValue === '' + value) {
return;
}
@@ -2297,6 +2301,7 @@ function hydrateNumericAttribute(
if (__DEV__) {
checkAttributeStringCoercion(value, propKey);
}
// $FlowFixMe[invalid-compare]
if (serverValue === '' + value) {
return;
}
@@ -2348,6 +2353,7 @@ function hydratePositiveNumericAttribute(
if (__DEV__) {
checkAttributeStringCoercion(value, propKey);
}
// $FlowFixMe[invalid-compare]
if (serverValue === '' + value) {
return;
}
@@ -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
@@ -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;
}
+33 -22
View File
@@ -1112,6 +1112,7 @@ export function appendChildToContainer(
// https://github.com/facebook/react/issues/11918
const reactRootContainer = container._reactRootContainer;
if (
// $FlowFixMe[invalid-compare]
(reactRootContainer === null || reactRootContainer === undefined) &&
parentNode.onclick === null
) {
@@ -1419,6 +1420,7 @@ export function unhideInstance(instance: Instance, props: Props): void {
const styleProp = props[STYLE];
const display =
styleProp !== undefined &&
// $FlowFixMe[invalid-compare]
styleProp !== null &&
styleProp.hasOwnProperty('display')
? styleProp.display
@@ -1525,7 +1527,7 @@ export function applyViewTransitionName(
// https://bugs.webkit.org/show_bug.cgi?id=290923
const rects = instance.getClientRects();
if (
// $FlowFixMe[incompatible-call]
// $FlowFixMe[incompatible-type]
countClientRects(rects) === 1
) {
// If the instance has a single client rect, that means that it can be
@@ -1632,7 +1634,7 @@ export function cancelViewTransitionName(
if (documentElement !== null) {
documentElement.animate(
{opacity: [0, 0], pointerEvents: ['none', 'none']},
// $FlowFixMe[incompatible-call]
// $FlowFixMe[incompatible-type]
{
duration: 0,
fill: 'forwards',
@@ -1669,7 +1671,7 @@ export function cancelRootViewTransitionName(rootContainer: Container): void {
documentElement.style.viewTransitionName = 'none';
documentElement.animate(
{opacity: [0, 0], pointerEvents: ['none', 'none']},
// $FlowFixMe[incompatible-call]
// $FlowFixMe[incompatible-type]
{
duration: 0,
fill: 'forwards',
@@ -1686,6 +1688,7 @@ export function cancelRootViewTransitionName(rootContainer: Container): void {
documentElement.animate(
{width: [0, 0], height: [0, 0]},
// $FlowFixMe[incompatible-call]
// $FlowFixMe[incompatible-type]
{
duration: 0,
fill: 'forwards',
@@ -1782,11 +1785,11 @@ function moveOutOfViewport(
// while still letting it paint its "old" state to a snapshot.
const transform = getComputedTransform(originalStyle);
// Clear the long form properties.
// $FlowFixMe
// $FlowFixMe[prop-missing]
element.style.translate = 'none';
// $FlowFixMe
// $FlowFixMe[prop-missing]
element.style.scale = 'none';
// $FlowFixMe
// $FlowFixMe[prop-missing]
element.style.rotate = 'none';
// Apply a translate to move it way out of the viewport. This is applied first
// so that it is in the coordinate space of the parent and not after applying
@@ -1869,7 +1872,7 @@ export function cloneRootViewTransitionContainer(
if (getComputedStyle(positionedAncestor).position !== 'static') {
break;
}
// $FlowFixMe: This is refined.
// $FlowFixMe[incompatible-type]: This is refined.
positionedAncestor = positionedAncestor.parentNode;
}
@@ -2267,11 +2270,12 @@ export function startViewTransition(
const documentElement: Element = (ownerDocument.documentElement: any);
// Loop through all View Transition Animations.
// $FlowFixMe[prop-missing]
// $FlowFixMe[incompatible-type]
const animations = documentElement.getAnimations({subtree: true});
for (let i = 0; i < animations.length; i++) {
const animation = animations[i];
const effect: KeyframeEffect = (animation.effect: any);
// $FlowFixMe
// $FlowFixMe[prop-missing]
const pseudoElement: ?string = effect.pseudoElement;
if (
pseudoElement != null &&
@@ -2313,13 +2317,13 @@ export function startViewTransition(
height !== undefined
) {
// Replace the keyframes with ones that don't animate the width/height.
// $FlowFixMe
// $FlowFixMe[incompatible-type]
effect.setKeyframes(keyframes);
// Read back the new animation to see what the underlying width/height of the pseudo-element was.
const computedStyle = getComputedStyle(
// $FlowFixMe
// $FlowFixMe[incompatible-type]
effect.target,
// $FlowFixMe
// $FlowFixMe[prop-missing]
effect.pseudoElement,
);
if (
@@ -2334,7 +2338,7 @@ export function startViewTransition(
const last = keyframes[keyframes.length - 1];
last.width = width;
last.height = height;
// $FlowFixMe
// $FlowFixMe[incompatible-type]
effect.setKeyframes(keyframes);
}
}
@@ -2536,7 +2540,7 @@ function animateGesture(
const reverse = rangeStart > rangeEnd;
if (timeline instanceof AnimationTimeline) {
// Native Timeline
// $FlowFixMe[incompatible-call]
// $FlowFixMe[incompatible-type]
const animation = targetElement.animate(keyframes, {
pseudoElement: pseudoElement,
// Set the timeline to the current gesture timeline to drive the updates.
@@ -2558,7 +2562,7 @@ function animateGesture(
viewTransitionAnimations.push(animation);
} else {
// Custom Timeline
// $FlowFixMe[incompatible-call]
// $FlowFixMe[incompatible-type]
const animation = targetElement.animate(keyframes, {
pseudoElement: pseudoElement,
// We reset all easing functions to linear so that it feels like you
@@ -2617,6 +2621,7 @@ export function startGestureTransition(
const documentElement: Element = (ownerDocument.documentElement: any);
// Loop through all View Transition Animations.
// $FlowFixMe[prop-missing]
// $FlowFixMe[incompatible-type]
const animations = documentElement.getAnimations({subtree: true});
// First do a pass to collect all known group and new items so we can look
// up if they exist later.
@@ -2626,7 +2631,7 @@ export function startGestureTransition(
let longestDuration = 0;
for (let i = 0; i < animations.length; i++) {
const effect: KeyframeEffect = (animations[i].effect: any);
// $FlowFixMe
// $FlowFixMe[prop-missing]
const pseudoElement: ?string = effect.pseudoElement;
if (pseudoElement == null) {
} else if (
@@ -2661,7 +2666,7 @@ export function startGestureTransition(
continue;
}
const effect: KeyframeEffect = (anim.effect: any);
// $FlowFixMe
// $FlowFixMe[prop-missing]
const pseudoElement: ?string = effect.pseudoElement;
if (
pseudoElement != null &&
@@ -2721,7 +2726,7 @@ export function startGestureTransition(
}
animateGesture(
effect.getKeyframes(),
// $FlowFixMe: Always documentElement atm.
// $FlowFixMe[incompatible-type]: Always documentElement atm.
effect.target,
pseudoElement,
timeline,
@@ -2749,7 +2754,7 @@ export function startGestureTransition(
const pseudoElementName = '::view-transition-group' + groupName;
animateGesture(
[{}, {}],
// $FlowFixMe: Always documentElement atm.
// $FlowFixMe[incompatible-type]: Always documentElement atm.
effect.target,
pseudoElementName,
timeline,
@@ -2770,6 +2775,7 @@ export function startGestureTransition(
// that never stops. This seems to keep all running Animations alive until
// we explicitly abort (or something forces the View Transition to cancel).
// $FlowFixMe[incompatible-call]
// $FlowFixMe[incompatible-type]
const blockingAnim = documentElement.animate([{}, {}], {
pseudoElement: '::view-transition',
duration: 1,
@@ -2892,6 +2898,7 @@ ViewTransitionPseudoElement.prototype.animate = function (
}
: Object.assign(
(// $FlowFixMe[prop-missing]
// $FlowFixMe[incompatible-type]
{}: KeyframeAnimationOptions),
options,
);
@@ -2908,6 +2915,7 @@ ViewTransitionPseudoElement.prototype.getAnimations = function (
const selector = this._selector;
const animations = scope.getAnimations(
// $FlowFixMe[prop-missing]
// $FlowFixMe[incompatible-type]
{subtree: true},
);
const result = [];
@@ -3352,7 +3360,7 @@ FragmentInstance.prototype.getRootNode = function (
const parentHostInstance =
getInstanceFromHostFiber<Instance>(parentHostFiber);
const rootNode =
// $FlowFixMe[incompatible-cast] Flow expects Node
// $FlowFixMe[incompatible-type] Flow expects Node
(parentHostInstance.getRootNode(getRootNodeOptions): Document | ShadowRoot);
return rootNode;
};
@@ -3476,6 +3484,7 @@ function validateDocumentPositionWithFiberTree(
if (otherFiber === null) {
// otherFiber could be null if its the document or body element
const ownerDocument = otherNode.ownerDocument;
// $FlowFixMe[invalid-compare]
return otherNode === ownerDocument || otherNode === ownerDocument.body;
}
return isFragmentContainedByFiber(fragmentFiber, otherFiber);
@@ -4829,11 +4838,11 @@ export type HoistableRoot = Document | ShadowRoot;
export function getHoistableRoot(container: Container): HoistableRoot {
// $FlowFixMe[method-unbinding]
return typeof container.getRootNode === 'function'
? /* $FlowFixMe[incompatible-cast] Flow types this as returning a `Node`,
? /* $FlowFixMe[incompatible-type] Flow types this as returning a `Node`,
* but it's either a `Document` or `ShadowRoot`. */
(container.getRootNode(): Document | ShadowRoot)
: container.nodeType === DOCUMENT_NODE
? // $FlowFixMe[incompatible-cast] We've constrained this to be a Document which satisfies the return type
? // $FlowFixMe[incompatible-type] We've constrained this to be a Document which satisfies the return type
(container: Document)
: container.ownerDocument;
}
@@ -5151,12 +5160,14 @@ function preinitStyle(
}
// Construct a Resource and cache it
// $FlowFixMe[incompatible-type]
resource = {
type: 'stylesheet',
instance,
count: 1,
state,
};
// $FlowFixMe[incompatible-type]
styles.set(key, resource);
return;
}
@@ -5570,7 +5581,7 @@ function preloadStylesheet(
markNodeAsHoistable(instance);
(ownerDocument.head: any).appendChild(instance);
}
// $FlowFixMe: [incompatible-type] -- if instance is an Element it will also be an HTMLLinkElement
// $FlowFixMe[incompatible-type] -- if instance is an Element it will also be an HTMLLinkElement
state.preload = instance;
instance.addEventListener('load', () => (state.loading |= Loaded));
instance.addEventListener('error', () => (state.loading |= Errored));
@@ -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;
@@ -418,6 +418,7 @@ function isTagValidWithParent(
case 'rp':
case 'rt':
// $FlowFixMe[incompatible-type]
return impliedEndTags.indexOf(parentTag) === -1;
case 'caption':
@@ -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) {
@@ -216,6 +216,7 @@ function accumulateOrCreateContinuousQueuedReplayableEvent(
existingQueuedEvent.eventSystemFlags |= eventSystemFlags;
const targetContainers = existingQueuedEvent.targetContainers;
if (
// $FlowFixMe[invalid-compare]
targetContainer !== null &&
targetContainers.indexOf(targetContainer) === -1
) {
+3 -3
View File
@@ -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,
);
}
@@ -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);
}
@@ -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) {
@@ -1560,6 +1560,7 @@ function pushAttribute(
return;
}
case 'src': {
// $FlowFixMe[invalid-compare]
if (enableSrcObject && typeof value === 'object' && value !== null) {
if (typeof Blob === 'function' && value instanceof Blob) {
pushSrcObjectAttribute(target, value);
@@ -3367,7 +3368,7 @@ function pushImg(
// reenter this branch in a second pass for duplicate img hrefs.
promotablePreloads.delete(key);
// $FlowFixMe - Flow should understand that this is a Resource if the condition was true
// $FlowFixMe[incompatible-type] - Flow should understand that this is a Resource if the condition was true
renderState.highImagePreloads.add(resource);
}
} else if (!resumableState.imageResources.hasOwnProperty(key)) {
@@ -3563,6 +3564,8 @@ function pushTitle(
' tags to a single string value.',
childType,
);
// $FlowFixMe[invalid-compare]
// $FlowFixMe[constant-condition]
} else if (child && child.toString === {}.toString) {
if (child.$$typeof != null) {
console.error(
@@ -4019,8 +4022,10 @@ function pushStartCustomElement(
typeof propValue !== 'function' &&
typeof propValue !== 'symbol'
) {
// $FlowFixMe[invalid-compare]
if (propValue === false) {
continue;
// $FlowFixMe[invalid-compare]
} else if (propValue === true) {
propValue = '';
} else if (typeof propValue === 'object') {
@@ -4612,6 +4617,7 @@ export function writeStartPendingSuspenseBoundary(
): boolean {
writeChunk(destination, startPendingSuspenseBoundary1);
// $FlowFixMe[invalid-compare]
if (id === null) {
throw new Error(
'An ID must have been assigned before we can complete the boundary.',
+2 -2
View File
@@ -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<R>(fn: (() => R) | void): R | void {
);
}
}
// $FlowFixMe[incompatible-call]
// $FlowFixMe[incompatible-type]
return flushSyncWithoutWarningIfAlreadyRendering(fn);
}
@@ -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();
+3
View File
@@ -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;
+3 -2
View File
@@ -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,
@@ -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.
+2 -1
View File
@@ -78,7 +78,7 @@ function renderToReadableStream(
{
type: 'direct',
pull: (controller): ?Promise<void> => {
// $FlowIgnore
// $FlowFixMe[incompatible-type]
startFlowing(request, controller);
},
cancel: (reason): ?Promise<void> => {
@@ -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.
@@ -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.
@@ -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.
@@ -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},
);
@@ -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},
);
@@ -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},
);
+1 -1
View File
@@ -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);
}
+1
View File
@@ -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'
) {
+1 -1
View File
@@ -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});
@@ -51,7 +51,7 @@ const FunctionBind = Function.prototype.bind;
// $FlowFixMe[method-unbinding]
const ArraySlice = Array.prototype.slice;
function bind(this: ServerReference<any>): any {
// $FlowFixMe[incompatible-call]
// $FlowFixMe[incompatible-type]
const newFn = FunctionBind.apply(this, arguments);
if (this.$$typeof === SERVER_REFERENCE_TAG) {
if (__DEV__) {
@@ -223,7 +223,7 @@ export function byteLengthOfBinaryChunk(chunk: BinaryChunk): number {
}
export function closeWithError(destination: Destination, error: mixed): void {
// $FlowFixMe[incompatible-call]: This is an Error object or the destination accepts other types.
// $FlowFixMe[incompatible-type]: This is an Error object or the destination accepts other types.
destination.destroy(error);
}
@@ -164,7 +164,7 @@ export function getModuleDebugInfo<T>(
if (ioInfo === undefined) {
let href;
try {
// $FlowFixMe
// $FlowFixMe[incompatible-type]
href = new URL(filename, document.baseURI).href;
} catch (_) {
href = filename;
@@ -187,10 +187,10 @@ export function getModuleDebugInfo<T>(
}
}
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
@@ -144,11 +144,11 @@ function startReadingFromDebugChannelReadable(
const ws: WebSocket = (stream: any);
ws.binaryType = 'arraybuffer';
ws.addEventListener('message', event => {
// $FlowFixMe
// $FlowFixMe[incompatible-type]
onData(event.data);
});
ws.addEventListener('error', event => {
// $FlowFixMe
// $FlowFixMe[prop-missing]
onError(event.error);
});
ws.addEventListener('close', onClose);
@@ -339,7 +339,7 @@ function decodeReplyFromBusboy<T>(
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,
);
});
+2 -2
View File
@@ -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<ReactNodeList>(flightResponse);
const fizzRequest = createFizzRequest(
// $FlowFixMe: Thenables as children are supported.
// $FlowFixMe[incompatible-type]: Thenables as children are supported.
root,
resumableState,
createRenderState(
+2
View File
@@ -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);
@@ -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;
}
@@ -103,7 +103,7 @@ export function dispatchEvent(
const stateNode = targetFiber.stateNode;
// Guard against Fiber being unmounted
if (stateNode != null) {
// $FlowExpectedError[incompatible-cast] public instances in Fabric do not implement `EventTarget` yet.
// $FlowExpectedError[incompatible-type] public instances in Fabric do not implement `EventTarget` yet.
eventTarget = (getPublicInstance(stateNode): EventTarget);
}
}
@@ -155,6 +155,7 @@ export type RendererInspectionConfig = $ReadOnly<{
}>;
// TODO: Remove this conditional once all changes have propagated.
// $FlowFixMe[constant-condition]
if (registerEventHandler) {
/**
* Register the event emitter with the native bridge
@@ -392,6 +393,7 @@ export function resolveUpdatePriority(): EventPriority {
return currentUpdatePriority;
}
// $FlowFixMe[constant-condition]
const currentEventPriority = fabricGetCurrentEventPriority
? fabricGetCurrentEventPriority()
: null;
@@ -705,8 +707,9 @@ FragmentInstance.prototype.observeUsing = function (
traverseFragmentInstance(this._fragmentFiber, observeChild, observer);
};
function observeChild(child: Fiber, observer: IntersectionObserver) {
// $FlowFixMe[incompatible-type]
const publicInstance = getPublicInstanceFromHostFiber(child);
// $FlowFixMe[incompatible-call] DOM types expect Element
// $FlowFixMe[incompatible-type] DOM types expect Element
observer.observe(publicInstance);
return false;
}
@@ -729,8 +732,9 @@ FragmentInstance.prototype.unobserveUsing = function (
}
};
function unobserveChild(child: Fiber, observer: IntersectionObserver) {
// $FlowFixMe[incompatible-type]
const publicInstance = getPublicInstanceFromHostFiber(child);
// $FlowFixMe[incompatible-call] DOM types expect Element
// $FlowFixMe[incompatible-type] DOM types expect Element
observer.unobserve(publicInstance);
return false;
}
@@ -893,8 +897,9 @@ export function commitNewChildToFragmentInstance(
if (publicInstance == null) {
throw new Error('Expected to find a host node. This is a bug in React.');
}
// $FlowFixMe[incompatible-type]
fragmentInstance._observers.forEach(observer => {
// $FlowFixMe[incompatible-call] Element types are behind a flag in RN
// $FlowFixMe[incompatible-type] Element types are behind a flag in RN
observer.observe(publicInstance);
});
}
@@ -94,7 +94,7 @@ export function cloneRootViewTransitionContainer(
if (__DEV__) {
console.warn('cloneRootViewTransitionContainer is not implemented');
}
// $FlowFixMe[incompatible-return] Return empty stub
// $FlowFixMe[incompatible-type] Return empty stub
return null;
}
@@ -59,7 +59,7 @@ export function findHostInstance_DEPRECATED<TElementType: ElementType>(
componentOrHandle.canonical &&
componentOrHandle.canonical.publicInstance
) {
// $FlowExpectedError[incompatible-return] Can't refine componentOrHandle as a Fabric instance
// $FlowExpectedError[incompatible-type] Can't refine componentOrHandle as a Fabric instance
return componentOrHandle.canonical.publicInstance;
}
@@ -75,7 +75,7 @@ export function findHostInstance_DEPRECATED<TElementType: ElementType>(
// findHostInstance handles legacy vs. Fabric differences correctly
// $FlowFixMe[incompatible-exact] we need to fix the definition of `HostComponent` to use NativeMethods as an interface, not as a type.
// $FlowFixMe[incompatible-return]
// $FlowFixMe[incompatible-type]
return hostInstance;
}
@@ -132,11 +132,11 @@ export function findNodeHandle(componentOrHandle: any): ?number {
}
if (hostInstance == null) {
// $FlowFixMe[incompatible-return] Flow limitation in refining an opaque type
// $FlowFixMe[incompatible-type] Flow limitation in refining an opaque type
return hostInstance;
}
// $FlowFixMe[incompatible-call] Necessary when running Flow on the legacy renderer
// $FlowFixMe[incompatible-type] Necessary when running Flow on the legacy renderer
return getNativeTagFromPublicInstance(hostInstance);
}
@@ -178,9 +178,9 @@ export function getNodeFromInternalInstanceHandle(
internalInstanceHandle: mixed,
): ?Node {
return (
// $FlowExpectedError[incompatible-return] internalInstanceHandle is opaque but we need to make an exception here.
// $FlowExpectedError[incompatible-type] internalInstanceHandle is opaque but we need to make an exception here.
internalInstanceHandle &&
// $FlowExpectedError[incompatible-return]
// $FlowExpectedError[incompatible-type]
internalInstanceHandle.stateNode &&
// $FlowExpectedError[incompatible-use]
internalInstanceHandle.stateNode.node

Some files were not shown because too many files have changed in this diff Show More