Flow upgrade to 0.153

- method unbinding is no longer supported in Flow for soundness, this added a bunch of suppressions
- Flow now prevents objects to be supertypes of interfaces/classes

ghstack-source-id: d7749cbad8
Pull Request resolved: https://github.com/facebook/react/pull/25412
This commit is contained in:
Jan Kassens 2022-10-04 11:04:47 -04:00
parent adb58f529d
commit 9f8a98a390
52 changed files with 110 additions and 38 deletions

View File

@ -63,7 +63,7 @@
"eslint-plugin-react-internal": "link:./scripts/eslint-rules", "eslint-plugin-react-internal": "link:./scripts/eslint-rules",
"fbjs-scripts": "1.2.0", "fbjs-scripts": "1.2.0",
"filesize": "^6.0.1", "filesize": "^6.0.1",
"flow-bin": "^0.152.0", "flow-bin": "^0.153.0",
"glob": "^7.1.6", "glob": "^7.1.6",
"glob-stream": "^6.1.0", "glob-stream": "^6.1.0",
"google-closure-compiler": "^20200517.0.0", "google-closure-compiler": "^20200517.0.0",

View File

@ -72,6 +72,7 @@ export function act<T>(scope: () => Thenable<T> | T): Thenable<T> {
if ( if (
typeof result === 'object' && typeof result === 'object' &&
result !== null && result !== null &&
// $FlowFixMe[method-unbinding]
typeof result.then === 'function' typeof result.then === 'function'
) { ) {
const thenableResult: Thenable<T> = (result: any); const thenableResult: Thenable<T> = (result: any);

View File

@ -13,7 +13,9 @@ import * as React from 'react';
import {createLRU} from './LRU'; import {createLRU} from './LRU';
type Suspender = {then(resolve: () => mixed, reject: () => mixed): mixed, ...}; interface Suspender {
then(resolve: () => mixed, reject: () => mixed): mixed;
}
type PendingResult = { type PendingResult = {
status: 0, status: 0,
@ -120,6 +122,7 @@ function accessResult<I, K, V>(
); );
const newResult: PendingResult = { const newResult: PendingResult = {
status: Pending, status: Pending,
// $FlowFixMe[method-unbinding]
value: thenable, value: thenable,
}; };
// $FlowFixMe[escaped-generic] discovered when updating Flow // $FlowFixMe[escaped-generic] discovered when updating Flow

View File

@ -11,10 +11,13 @@ import {__PERFORMANCE_PROFILE__} from './constants';
const supportsUserTiming = const supportsUserTiming =
typeof performance !== 'undefined' && typeof performance !== 'undefined' &&
// $FlowFixMe[method-unbinding]
typeof performance.mark === 'function' && typeof performance.mark === 'function' &&
// $FlowFixMe[method-unbinding]
typeof performance.clearMarks === 'function'; typeof performance.clearMarks === 'function';
const supportsPerformanceNow = const supportsPerformanceNow =
// $FlowFixMe[method-unbinding]
typeof performance !== 'undefined' && typeof performance.now === 'function'; typeof performance !== 'undefined' && typeof performance.now === 'function';
function mark(markName: string): void { function mark(markName: string): void {

View File

@ -44,7 +44,9 @@ let performanceTarget: Performance | null = null;
// If performance exists and supports the subset of the User Timing API that we require. // If performance exists and supports the subset of the User Timing API that we require.
let supportsUserTiming = let supportsUserTiming =
typeof performance !== 'undefined' && typeof performance !== 'undefined' &&
// $FlowFixMe[method-unbinding]
typeof performance.mark === 'function' && typeof performance.mark === 'function' &&
// $FlowFixMe[method-unbinding]
typeof performance.clearMarks === 'function'; typeof performance.clearMarks === 'function';
let supportsUserTimingV3 = false; let supportsUserTimingV3 = false;
@ -76,6 +78,7 @@ if (supportsUserTimingV3) {
// Some environments (e.g. React Native / Hermes) don't support the performance API yet. // Some environments (e.g. React Native / Hermes) don't support the performance API yet.
const getCurrentTime = const getCurrentTime =
// $FlowFixMe[method-unbinding]
typeof performance === 'object' && typeof performance.now === 'function' typeof performance === 'object' && typeof performance.now === 'function'
? () => performance.now() ? () => performance.now()
: () => Date.now(); : () => Date.now();

View File

@ -151,6 +151,7 @@ function getFiberFlags(fiber: Fiber): number {
// Some environments (e.g. React Native / Hermes) don't support the performance API yet. // Some environments (e.g. React Native / Hermes) don't support the performance API yet.
const getCurrentTime = const getCurrentTime =
// $FlowFixMe[method-unbinding]
typeof performance === 'object' && typeof performance.now === 'function' typeof performance === 'object' && typeof performance.now === 'function'
? () => performance.now() ? () => performance.now()
: () => Date.now(); : () => Date.now();

View File

@ -115,6 +115,7 @@ export default function setupHighlighter(
if (nodes != null && nodes[0] != null) { if (nodes != null && nodes[0] != null) {
const node = nodes[0]; const node = nodes[0];
// $FlowFixMe[method-unbinding]
if (scrollIntoView && typeof node.scrollIntoView === 'function') { if (scrollIntoView && typeof node.scrollIntoView === 'function') {
// If the node isn't visible show it before highlighting it. // If the node isn't visible show it before highlighting it.
// We may want to reconsider this; it might be a little disruptive. // We may want to reconsider this; it might be a little disruptive.

View File

@ -26,6 +26,7 @@ const REMEASUREMENT_AFTER_DURATION = 250;
// Some environments (e.g. React Native / Hermes) don't support the performance API yet. // Some environments (e.g. React Native / Hermes) don't support the performance API yet.
const getCurrentTime = const getCurrentTime =
// $FlowFixMe[method-unbinding]
typeof performance === 'object' && typeof performance.now === 'function' typeof performance === 'object' && typeof performance.now === 'function'
? () => performance.now() ? () => performance.now()
: () => Date.now(); : () => Date.now();

View File

@ -7,15 +7,14 @@
* @flow * @flow
*/ */
export type Rect = { export interface Rect {
bottom: number, bottom: number;
height: number, height: number;
left: number, left: number;
right: number, right: number;
top: number, top: number;
width: number, width: number;
... }
};
// Get the window object for the document that a node belongs to, // Get the window object for the document that a node belongs to,
// or return null if it cannot be found (node not attached to DOM, // or return null if it cannot be found (node not attached to DOM,

View File

@ -26,7 +26,9 @@ import {createContext} from 'react';
export type {Thenable}; export type {Thenable};
type Suspender = {then(resolve: () => mixed, reject: () => mixed): mixed, ...}; interface Suspender {
then(resolve: () => mixed, reject: () => mixed): mixed;
}
type PendingResult = { type PendingResult = {
status: 0, status: 0,
@ -124,6 +126,7 @@ function accessResult<Input, Key, Value>(
); );
const newResult: PendingResult = { const newResult: PendingResult = {
status: Pending, status: Pending,
// $FlowFixMe[method-unbinding]
value: thenable, value: thenable,
}; };
entriesForResource.set(key, newResult); entriesForResource.set(key, newResult);

View File

@ -33,6 +33,7 @@ import type {Element} from 'react-devtools-shared/src/devtools/views/Components/
import type {Element as ReactElement} from 'react'; import type {Element as ReactElement} from 'react';
import type {FrontendBridge} from 'react-devtools-shared/src/bridge'; import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
// $FlowFixMe[method-unbinding]
const hasOwnProperty = Object.prototype.hasOwnProperty; const hasOwnProperty = Object.prototype.hasOwnProperty;
type Type = 'props' | 'state' | 'context' | 'hooks'; type Type = 'props' | 'state' | 'context' | 'hooks';

View File

@ -67,6 +67,7 @@ export default function SidebarSelectedFiberInfo(_: Props): React.Node {
const selectedElement = selectedListItemRef.current; const selectedElement = selectedListItemRef.current;
if ( if (
selectedElement !== null && selectedElement !== null &&
// $FlowFixMe[method-unbinding]
typeof selectedElement.scrollIntoView === 'function' typeof selectedElement.scrollIntoView === 'function'
) { ) {
selectedElement.scrollIntoView({block: 'nearest', inline: 'nearest'}); selectedElement.scrollIntoView({block: 'nearest', inline: 'nearest'});

View File

@ -14,6 +14,7 @@ import isArray from 'react-devtools-shared/src/isArray';
import type {HooksTree} from 'react-debug-tools/src/ReactDebugHooks'; import type {HooksTree} from 'react-debug-tools/src/ReactDebugHooks';
// $FlowFixMe[method-unbinding]
const hasOwnProperty = Object.prototype.hasOwnProperty; const hasOwnProperty = Object.prototype.hasOwnProperty;
export function alphaSortEntries( export function alphaSortEntries(

View File

@ -61,6 +61,7 @@ export function installHook(target: any): DevToolsHook | null {
// it happens *outside* of the renderer injection. See `checkDCE` below. // it happens *outside* of the renderer injection. See `checkDCE` below.
} }
// $FlowFixMe[method-unbinding]
const toString = Function.prototype.toString; const toString = Function.prototype.toString;
if (renderer.Mount && renderer.Mount._renderNewRootComponent) { if (renderer.Mount && renderer.Mount._renderNewRootComponent) {
// React DOM Stack // React DOM Stack
@ -147,6 +148,7 @@ export function installHook(target: any): DevToolsHook | null {
// This runs for production versions of React. // This runs for production versions of React.
// Needs to be super safe. // Needs to be super safe.
try { try {
// $FlowFixMe[method-unbinding]
const toString = Function.prototype.toString; const toString = Function.prototype.toString;
const code = toString.call(fn); const code = toString.call(fn);

View File

@ -56,6 +56,7 @@ import isArray from './isArray';
import type {ComponentFilter, ElementType} from './types'; import type {ComponentFilter, ElementType} from './types';
import type {LRUCache} from 'react-devtools-shared/src/types'; import type {LRUCache} from 'react-devtools-shared/src/types';
// $FlowFixMe[method-unbinding]
const hasOwnProperty = Object.prototype.hasOwnProperty; const hasOwnProperty = Object.prototype.hasOwnProperty;
const cachedDisplayNames: WeakMap<Function, string> = new WeakMap(); const cachedDisplayNames: WeakMap<Function, string> = new WeakMap();
@ -598,6 +599,7 @@ export function getDataType(data: Object): DataType {
} else if (data.constructor && data.constructor.name === 'RegExp') { } else if (data.constructor && data.constructor.name === 'RegExp') {
return 'regexp'; return 'regexp';
} else { } else {
// $FlowFixMe[method-unbinding]
const toStringValue = Object.prototype.toString.call(data); const toStringValue = Object.prototype.toString.call(data);
if (toStringValue === '[object Date]') { if (toStringValue === '[object Date]') {
return 'date'; return 'date';
@ -612,6 +614,7 @@ export function getDataType(data: Object): DataType {
return 'symbol'; return 'symbol';
case 'undefined': case 'undefined':
if ( if (
// $FlowFixMe[method-unbinding]
Object.prototype.toString.call(data) === '[object HTMLAllCollection]' Object.prototype.toString.call(data) === '[object HTMLAllCollection]'
) { ) {
return 'html_all_collection'; return 'html_all_collection';

View File

@ -968,8 +968,11 @@ function preprocessFlamechart(rawData: TimelineEvent[]): Flamechart {
const profile = parsedData.profiles[0]; // TODO: Choose the main CPU thread only const profile = parsedData.profiles[0]; // TODO: Choose the main CPU thread only
const speedscopeFlamechart = new SpeedscopeFlamechart({ const speedscopeFlamechart = new SpeedscopeFlamechart({
// $FlowFixMe[method-unbinding]
getTotalWeight: profile.getTotalWeight.bind(profile), getTotalWeight: profile.getTotalWeight.bind(profile),
// $FlowFixMe[method-unbinding]
forEachCall: profile.forEachCall.bind(profile), forEachCall: profile.forEachCall.bind(profile),
// $FlowFixMe[method-unbinding]
formatValue: profile.formatValue.bind(profile), formatValue: profile.formatValue.bind(profile),
getColorBucketForFrame: () => 0, getColorBucketForFrame: () => 0,
}); });

View File

@ -455,6 +455,7 @@ export function createElement(
if (namespaceURI === HTML_NAMESPACE) { if (namespaceURI === HTML_NAMESPACE) {
if ( if (
!isCustomComponentTag && !isCustomComponentTag &&
// $FlowFixMe[method-unbinding]
Object.prototype.toString.call(domElement) === Object.prototype.toString.call(domElement) ===
'[object HTMLUnknownElement]' && '[object HTMLUnknownElement]' &&
!hasOwnProperty.call(warnedUnknownTags, type) !hasOwnProperty.call(warnedUnknownTags, type)

View File

@ -61,14 +61,17 @@ export function precacheFiberNode(
} }
export function markContainerAsRoot(hostRoot: Fiber, node: Container): void { export function markContainerAsRoot(hostRoot: Fiber, node: Container): void {
// $FlowFixMe[prop-missing]
node[internalContainerInstanceKey] = hostRoot; node[internalContainerInstanceKey] = hostRoot;
} }
export function unmarkContainerAsRoot(node: Container): void { export function unmarkContainerAsRoot(node: Container): void {
// $FlowFixMe[prop-missing]
node[internalContainerInstanceKey] = null; node[internalContainerInstanceKey] = null;
} }
export function isContainerMarkedAsRoot(node: Container): boolean { export function isContainerMarkedAsRoot(node: Container): boolean {
// $FlowFixMe[prop-missing]
return !!node[internalContainerInstanceKey]; return !!node[internalContainerInstanceKey];
} }
@ -132,6 +135,7 @@ export function getClosestInstanceFromNode(targetNode: Node): null | Fiber {
// have had an internalInstanceKey on it. // have had an internalInstanceKey on it.
// Let's get the fiber associated with the SuspenseComponent // Let's get the fiber associated with the SuspenseComponent
// as the deepest instance. // as the deepest instance.
// $FlowFixMe[prop-missing]
const targetSuspenseInst = suspenseInstance[internalInstanceKey]; const targetSuspenseInst = suspenseInstance[internalInstanceKey];
if (targetSuspenseInst) { if (targetSuspenseInst) {
return targetSuspenseInst; return targetSuspenseInst;

View File

@ -117,12 +117,14 @@ export type EventTargetChildElement = {
... ...
}; };
export type Container = export type Container =
| (Element & {_reactRootContainer?: FiberRoot, ...}) | interface extends Element {_reactRootContainer?: FiberRoot}
| (Document & {_reactRootContainer?: FiberRoot, ...}) | interface extends Document {_reactRootContainer?: FiberRoot}
| (DocumentFragment & {_reactRootContainer?: FiberRoot, ...}); | interface extends DocumentFragment {_reactRootContainer?: FiberRoot};
export type Instance = Element; export type Instance = Element;
export type TextInstance = Text; export type TextInstance = Text;
export type SuspenseInstance = Comment & {_reactRetry?: () => void, ...}; export interface SuspenseInstance extends Comment {
_reactRetry?: () => void;
}
export type HydratableInstance = Instance | TextInstance | SuspenseInstance; export type HydratableInstance = Instance | TextInstance | SuspenseInstance;
export type PublicInstance = Element | Text; export type PublicInstance = Element | Text;
type HostContextDev = { type HostContextDev = {
@ -644,6 +646,7 @@ export function hideInstance(instance: Instance): void {
// pass host context to this method? // pass host context to this method?
instance = ((instance: any): HTMLElement); instance = ((instance: any): HTMLElement);
const style = instance.style; const style = instance.style;
// $FlowFixMe[method-unbinding]
if (typeof style.setProperty === 'function') { if (typeof style.setProperty === 'function') {
style.setProperty('display', 'none', 'important'); style.setProperty('display', 'none', 'important');
} else { } else {
@ -679,6 +682,7 @@ export function clearContainer(container: Container): void {
((container: any): Element).textContent = ''; ((container: any): Element).textContent = '';
} else if (container.nodeType === DOCUMENT_NODE) { } else if (container.nodeType === DOCUMENT_NODE) {
if (container.documentElement) { if (container.documentElement) {
// $FlowFixMe[incompatible-call]
container.removeChild(container.documentElement); container.removeChild(container.documentElement);
} }
} }
@ -1267,6 +1271,7 @@ export function setFocusIfFocusable(node: Instance): boolean {
const element = ((node: any): HTMLElement); const element = ((node: any): HTMLElement);
try { try {
element.addEventListener('focus', handleFocus); element.addEventListener('focus', handleFocus);
// $FlowFixMe[method-unbinding]
(element.focus || HTMLElement.prototype.focus).call(element); (element.focus || HTMLElement.prototype.focus).call(element);
} finally { } finally {
element.removeEventListener('focus', handleFocus); element.removeEventListener('focus', handleFocus);
@ -1349,11 +1354,13 @@ export const supportsResources = true;
export {isHostResourceType}; export {isHostResourceType};
function isHostResourceInstance(instance: Instance | Container): boolean { function isHostResourceInstance(instance: Instance | Container): boolean {
if (instance.nodeType === ELEMENT_NODE) { if (instance.nodeType === ELEMENT_NODE) {
// $FlowFixMe[prop-missing] Flow doesn't understand `nodeType` test.
switch (instance.tagName.toLowerCase()) { switch (instance.tagName.toLowerCase()) {
case 'link': { case 'link': {
const rel = ((instance: any): HTMLLinkElement).rel; const rel = ((instance: any): HTMLLinkElement).rel;
return ( return (
rel === 'preload' || rel === 'preload' ||
// $FlowFixMe[prop-missing] Flow doesn't understand `nodeType` test.
(rel === 'stylesheet' && instance.hasAttribute('data-rprec')) (rel === 'stylesheet' && instance.hasAttribute('data-rprec'))
); );
} }

View File

@ -73,11 +73,7 @@ function updateOptions(
propValue: any, propValue: any,
setDefaultSelected: boolean, setDefaultSelected: boolean,
) { ) {
type IndexableHTMLOptionsCollection = HTMLOptionsCollection & { const options: HTMLOptionsCollection = node.options;
[key: number]: HTMLOptionElement,
...,
};
const options: IndexableHTMLOptionsCollection = node.options;
if (multiple) { if (multiple) {
const selectedValues = (propValue: Array<string>); const selectedValues = (propValue: Array<string>);

View File

@ -14,8 +14,9 @@ type ValueTracker = {
setValue(value: string): void, setValue(value: string): void,
stopTracking(): void, stopTracking(): void,
}; };
type WrapperState = {_valueTracker?: ?ValueTracker, ...}; interface ElementWithValueTracker extends HTMLInputElement {
type ElementWithValueTracker = HTMLInputElement & WrapperState; _valueTracker?: ?ValueTracker;
}
function isCheckable(elem: HTMLInputElement) { function isCheckable(elem: HTMLInputElement) {
const type = elem.type; const type = elem.type;

View File

@ -761,7 +761,7 @@ export function accumulateSinglePhaseListeners(
// current instance fiber. In which case, we should clear all existing // current instance fiber. In which case, we should clear all existing
// listeners. // listeners.
if (enableCreateEventHandleAPI && nativeEvent.type === 'beforeblur') { if (enableCreateEventHandleAPI && nativeEvent.type === 'beforeblur') {
// $FlowFixMe: internal field // $FlowFixMe[prop-missing] internal field
const detachedInterceptFiber = nativeEvent._detachedInterceptFiber; const detachedInterceptFiber = nativeEvent._detachedInterceptFiber;
if ( if (
detachedInterceptFiber !== null && detachedInterceptFiber !== null &&

View File

@ -7,11 +7,10 @@
* @flow * @flow
*/ */
export type Destination = { export interface Destination {
push(chunk: string | null): boolean, push(chunk: string | null): boolean;
destroy(error: Error): mixed, destroy(error: Error): mixed;
... }
};
export type PrecomputedChunk = string; export type PrecomputedChunk = string;
export type Chunk = string; export type Chunk = string;

View File

@ -145,6 +145,7 @@ function legacyCreateRootFromDOMContainer(
const rootContainerElement = const rootContainerElement =
container.nodeType === COMMENT_NODE ? container.parentNode : container; container.nodeType === COMMENT_NODE ? container.parentNode : container;
// $FlowFixMe[incompatible-call]
listenToAllSupportedEvents(rootContainerElement); listenToAllSupportedEvents(rootContainerElement);
flushSync(); flushSync();
@ -179,6 +180,7 @@ function legacyCreateRootFromDOMContainer(
const rootContainerElement = const rootContainerElement =
container.nodeType === COMMENT_NODE ? container.parentNode : container; container.nodeType === COMMENT_NODE ? container.parentNode : container;
// $FlowFixMe[incompatible-call]
listenToAllSupportedEvents(rootContainerElement); listenToAllSupportedEvents(rootContainerElement);
// Initial mount should not be batched. // Initial mount should not be batched.
@ -435,6 +437,8 @@ export function unmountComponentAtNode(container: Container): boolean {
const isContainerReactRoot = const isContainerReactRoot =
container.nodeType === ELEMENT_NODE && container.nodeType === ELEMENT_NODE &&
isValidContainerLegacy(container.parentNode) && isValidContainerLegacy(container.parentNode) &&
// $FlowFixMe[prop-missing]
// $FlowFixMe[incompatible-use]
!!container.parentNode._reactRootContainer; !!container.parentNode._reactRootContainer;
if (hasNonRootReactChild) { if (hasNonRootReactChild) {

View File

@ -115,6 +115,7 @@ export function dispatchEvent(
// Note that extracted events are *not* emitted, // Note that extracted events are *not* emitted,
// only events that have a 1:1 mapping with a native event, at least for now. // only events that have a 1:1 mapping with a native event, at least for now.
const event = {eventName: topLevelType, nativeEvent}; const event = {eventName: topLevelType, nativeEvent};
// $FlowFixMe[class-object-subtyping] found when upgrading Flow
RawEventEmitter.emit(topLevelType, event); RawEventEmitter.emit(topLevelType, event);
RawEventEmitter.emit('*', event); RawEventEmitter.emit('*', event);

View File

@ -316,6 +316,7 @@ class ReactFabricHostComponent {
} }
// eslint-disable-next-line no-unused-expressions // eslint-disable-next-line no-unused-expressions
// $FlowFixMe[class-object-subtyping] found when upgrading Flow
(ReactFabricHostComponent.prototype: $ReadOnly<{...NativeMethods, ...}>); (ReactFabricHostComponent.prototype: $ReadOnly<{...NativeMethods, ...}>);
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoMutation'; export * from 'react-reconciler/src/ReactFiberHostConfigWithNoMutation';

View File

@ -127,6 +127,7 @@ class ReactNativeFiberHostComponent {
} }
// eslint-disable-next-line no-unused-expressions // eslint-disable-next-line no-unused-expressions
// $FlowFixMe[class-object-subtyping] found when upgrading Flow
(ReactNativeFiberHostComponent.prototype: $ReadOnly<{...NativeMethods, ...}>); (ReactNativeFiberHostComponent.prototype: $ReadOnly<{...NativeMethods, ...}>);
export default ReactNativeFiberHostComponent; export default ReactNativeFiberHostComponent;

View File

@ -219,6 +219,7 @@ export function injectEventPluginOrder(
} }
// Clone the ordering so it cannot be dynamically mutated. // Clone the ordering so it cannot be dynamically mutated.
// $FlowFixMe[method-unbinding] found when upgrading Flow
eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder);
recomputePluginOrdering(); recomputePluginOrdering();
} }

View File

@ -228,6 +228,7 @@ function coerceRef(
} }
function throwOnInvalidObjectType(returnFiber: Fiber, newChild: Object) { function throwOnInvalidObjectType(returnFiber: Fiber, newChild: Object) {
// $FlowFixMe[method-unbinding]
const childString = Object.prototype.toString.call(newChild); const childString = Object.prototype.toString.call(newChild);
throw new Error( throw new Error(

View File

@ -228,6 +228,7 @@ function coerceRef(
} }
function throwOnInvalidObjectType(returnFiber: Fiber, newChild: Object) { function throwOnInvalidObjectType(returnFiber: Fiber, newChild: Object) {
// $FlowFixMe[method-unbinding]
const childString = Object.prototype.toString.call(newChild); const childString = Object.prototype.toString.call(newChild);
throw new Error( throw new Error(

View File

@ -2336,6 +2336,7 @@ function getRetryCache(finishedWork) {
const instance: OffscreenInstance = finishedWork.stateNode; const instance: OffscreenInstance = finishedWork.stateNode;
let retryCache = instance._retryCache; let retryCache = instance._retryCache;
if (retryCache === null) { if (retryCache === null) {
// $FlowFixMe[incompatible-type]
retryCache = instance._retryCache = new PossiblyWeakSet(); retryCache = instance._retryCache = new PossiblyWeakSet();
} }
return retryCache; return retryCache;

View File

@ -2336,6 +2336,7 @@ function getRetryCache(finishedWork) {
const instance: OffscreenInstance = finishedWork.stateNode; const instance: OffscreenInstance = finishedWork.stateNode;
let retryCache = instance._retryCache; let retryCache = instance._retryCache;
if (retryCache === null) { if (retryCache === null) {
// $FlowFixMe[incompatible-type]
retryCache = instance._retryCache = new PossiblyWeakSet(); retryCache = instance._retryCache = new PossiblyWeakSet();
} }
return retryCache; return retryCache;

View File

@ -768,6 +768,8 @@ if (enableUseMemoCacheHook) {
function use<T>(usable: Usable<T>): T { function use<T>(usable: Usable<T>): T {
if (usable !== null && typeof usable === 'object') { if (usable !== null && typeof usable === 'object') {
// $FlowFixMe[method-unbinding]
// $FlowFixMe[prop-missing]
if (typeof usable.then === 'function') { if (typeof usable.then === 'function') {
// This is a thenable. // This is a thenable.
const thenable: Thenable<T> = (usable: any); const thenable: Thenable<T> = (usable: any);

View File

@ -768,6 +768,8 @@ if (enableUseMemoCacheHook) {
function use<T>(usable: Usable<T>): T { function use<T>(usable: Usable<T>): T {
if (usable !== null && typeof usable === 'object') { if (usable !== null && typeof usable === 'object') {
// $FlowFixMe[method-unbinding]
// $FlowFixMe[prop-missing]
if (typeof usable.then === 'function') { if (typeof usable.then === 'function') {
// This is a thenable. // This is a thenable.
const thenable: Thenable<T> = (usable: any); const thenable: Thenable<T> = (usable: any);

View File

@ -51,5 +51,6 @@ export type OffscreenInstance = {
_visibility: OffscreenVisibility, _visibility: OffscreenVisibility,
_pendingMarkers: Set<TracingMarkerInstance> | null, _pendingMarkers: Set<TracingMarkerInstance> | null,
_transitions: Set<Transition> | null, _transitions: Set<Transition> | null,
// $FlowFixMe[incompatible-type-arg] found when upgrading Flow
_retryCache: WeakSet<Wakeable> | Set<Wakeable> | null, _retryCache: WeakSet<Wakeable> | Set<Wakeable> | null,
}; };

View File

@ -1213,6 +1213,7 @@ export function queueRecoverableErrors(errors: Array<CapturedValue<mixed>>) {
if (workInProgressRootRecoverableErrors === null) { if (workInProgressRootRecoverableErrors === null) {
workInProgressRootRecoverableErrors = errors; workInProgressRootRecoverableErrors = errors;
} else { } else {
// $FlowFixMe[method-unbinding]
workInProgressRootRecoverableErrors.push.apply( workInProgressRootRecoverableErrors.push.apply(
workInProgressRootRecoverableErrors, workInProgressRootRecoverableErrors,
errors, errors,
@ -3169,6 +3170,7 @@ export function resolveRetryWakeable(boundaryFiber: Fiber, wakeable: Wakeable) {
break; break;
case OffscreenComponent: { case OffscreenComponent: {
const instance: OffscreenInstance = boundaryFiber.stateNode; const instance: OffscreenInstance = boundaryFiber.stateNode;
// $FlowFixMe[incompatible-type] found when upgrading Flow
retryCache = instance._retryCache; retryCache = instance._retryCache;
break; break;
} }

View File

@ -1213,6 +1213,7 @@ export function queueRecoverableErrors(errors: Array<CapturedValue<mixed>>) {
if (workInProgressRootRecoverableErrors === null) { if (workInProgressRootRecoverableErrors === null) {
workInProgressRootRecoverableErrors = errors; workInProgressRootRecoverableErrors = errors;
} else { } else {
// $FlowFixMe[method-unbinding]
workInProgressRootRecoverableErrors.push.apply( workInProgressRootRecoverableErrors.push.apply(
workInProgressRootRecoverableErrors, workInProgressRootRecoverableErrors,
errors, errors,
@ -3169,6 +3170,7 @@ export function resolveRetryWakeable(boundaryFiber: Fiber, wakeable: Wakeable) {
break; break;
case OffscreenComponent: { case OffscreenComponent: {
const instance: OffscreenInstance = boundaryFiber.stateNode; const instance: OffscreenInstance = boundaryFiber.stateNode;
// $FlowFixMe[incompatible-type] found when upgrading Flow
retryCache = instance._retryCache; retryCache = instance._retryCache;
break; break;
} }

View File

@ -74,6 +74,7 @@ export function preloadModule<T>(
if (entry === undefined) { if (entry === undefined) {
const thenable = __webpack_chunk_load__(chunkId); const thenable = __webpack_chunk_load__(chunkId);
promises.push(thenable); promises.push(thenable);
// $FlowFixMe[method-unbinding]
const resolve = chunkCache.set.bind(chunkCache, chunkId, null); const resolve = chunkCache.set.bind(chunkCache, chunkId, null);
thenable.then(resolve, ignoreReject); thenable.then(resolve, ignoreReject);
chunkCache.set(chunkId, thenable); chunkCache.set(chunkId, thenable);

View File

@ -59,6 +59,7 @@ module.exports = function register() {
async: true, async: true,
}; };
return Promise.resolve( return Promise.resolve(
// $FlowFixMe[incompatible-call] found when upgrading Flow
resolve(new Proxy(moduleReference, proxyHandlers)), resolve(new Proxy(moduleReference, proxyHandlers)),
); );
}; };

View File

@ -351,6 +351,7 @@ export default class ReactFlightWebpackPlugin {
if (err) return callback(err); if (err) return callback(err);
const flat = []; const flat = [];
for (let i = 0; i < result.length; i++) { for (let i = 0; i < result.length; i++) {
// $FlowFixMe[method-unbinding]
flat.push.apply(flat, result[i]); flat.push.apply(flat, result[i]);
} }
callback(null, flat); callback(null, flat);

View File

@ -589,6 +589,8 @@ function useId(): string {
function use<T>(usable: Usable<T>): T { function use<T>(usable: Usable<T>): T {
if (usable !== null && typeof usable === 'object') { if (usable !== null && typeof usable === 'object') {
// $FlowFixMe[method-unbinding]
// $FlowFixMe[prop-missing]
if (typeof usable.then === 'function') { if (typeof usable.then === 'function') {
// This is a thenable. // This is a thenable.
const thenable: Thenable<T> = (usable: any); const thenable: Thenable<T> = (usable: any);

View File

@ -1455,6 +1455,7 @@ function renderNodeDestructiveImpl(
} }
} }
// $FlowFixMe[method-unbinding]
const childString = Object.prototype.toString.call(node); const childString = Object.prototype.toString.call(node);
throw new Error( throw new Error(

View File

@ -145,6 +145,8 @@ function useId(): string {
function use<T>(usable: Usable<T>): T { function use<T>(usable: Usable<T>): T {
if (usable !== null && typeof usable === 'object') { if (usable !== null && typeof usable === 'object') {
// $FlowFixMe[method-unbinding]
// $FlowFixMe[prop-missing]
if (typeof usable.then === 'function') { if (typeof usable.then === 'function') {
// This is a thenable. // This is a thenable.
const thenable: Thenable<T> = (usable: any); const thenable: Thenable<T> = (usable: any);

View File

@ -435,6 +435,7 @@ function isSimpleObject(object): boolean {
} }
function objectName(object): string { function objectName(object): string {
// $FlowFixMe[method-unbinding]
const name = Object.prototype.toString.call(object); const name = Object.prototype.toString.call(object);
return name.replace(/^\[object (.*)\]$/, function(m, p0) { return name.replace(/^\[object (.*)\]$/, function(m, p0) {
return p0; return p0;
@ -494,6 +495,7 @@ function describeObjectForErrorMessage(
typeof value === 'object' && typeof value === 'object' &&
value !== null value !== null
) { ) {
// $FlowFixMe[incompatible-call] found when upgrading Flow
str += describeObjectForErrorMessage(value); str += describeObjectForErrorMessage(value);
} else { } else {
str += describeValueForErrorMessage(value); str += describeValueForErrorMessage(value);
@ -521,6 +523,7 @@ function describeObjectForErrorMessage(
typeof value === 'object' && typeof value === 'object' &&
value !== null value !== null
) { ) {
// $FlowFixMe[incompatible-call] found when upgrading Flow
str += describeObjectForErrorMessage(value); str += describeObjectForErrorMessage(value);
} else { } else {
str += describeValueForErrorMessage(value); str += describeValueForErrorMessage(value);

View File

@ -115,6 +115,7 @@ export function stringToPrecomputedChunk(content: string): PrecomputedChunk {
} }
export function closeWithError(destination: Destination, error: mixed): void { export function closeWithError(destination: Destination, error: mixed): void {
// $FlowFixMe[method-unbinding]
if (typeof destination.error === 'function') { if (typeof destination.error === 'function') {
// $FlowFixMe: This is an Error object or the destination accepts other types. // $FlowFixMe: This is an Error object or the destination accepts other types.
destination.error(error); destination.error(error);

View File

@ -10,10 +10,9 @@
import type {Writable} from 'stream'; import type {Writable} from 'stream';
import {TextEncoder} from 'util'; import {TextEncoder} from 'util';
type MightBeFlushable = { interface MightBeFlushable {
flush?: () => void, flush?: () => void;
... }
};
export type Destination = Writable & MightBeFlushable; export type Destination = Writable & MightBeFlushable;

View File

@ -60,6 +60,7 @@ export function act<T>(callback: () => T | Thenable<T>): Thenable<T> {
if ( if (
result !== null && result !== null &&
typeof result === 'object' && typeof result === 'object' &&
// $FlowFixMe[method-unbinding]
typeof result.then === 'function' typeof result.then === 'function'
) { ) {
const thenableResult: Thenable<T> = (result: any); const thenableResult: Thenable<T> = (result: any);

View File

@ -58,6 +58,7 @@ type Task = {
let getCurrentTime: () => number | DOMHighResTimeStamp; let getCurrentTime: () => number | DOMHighResTimeStamp;
const hasPerformanceNow = const hasPerformanceNow =
// $FlowFixMe[method-unbinding]
typeof performance === 'object' && typeof performance.now === 'function'; typeof performance === 'object' && typeof performance.now === 'function';
if (hasPerformanceNow) { if (hasPerformanceNow) {

View File

@ -7,6 +7,7 @@
* @flow * @flow
*/ */
// $FlowFixMe[method-unbinding]
const hasOwnProperty = Object.prototype.hasOwnProperty; const hasOwnProperty = Object.prototype.hasOwnProperty;
export default hasOwnProperty; export default hasOwnProperty;

View File

@ -12,6 +12,7 @@ function invokeGuardedCallbackProd<Args: Array<mixed>, Context>(
func: (...Args) => mixed, func: (...Args) => mixed,
context: Context, context: Context,
): void { ): void {
// $FlowFixMe[method-unbinding]
const funcArgs = Array.prototype.slice.call(arguments, 3); const funcArgs = Array.prototype.slice.call(arguments, 3);
try { try {
// $FlowFixMe[incompatible-call] Flow doesn't understand the arguments splicing. // $FlowFixMe[incompatible-call] Flow doesn't understand the arguments splicing.
@ -53,6 +54,7 @@ if (__DEV__) {
typeof window !== 'undefined' && typeof window !== 'undefined' &&
typeof window.dispatchEvent === 'function' && typeof window.dispatchEvent === 'function' &&
typeof document !== 'undefined' && typeof document !== 'undefined' &&
// $FlowFixMe[method-unbinding]
typeof document.createEvent === 'function' typeof document.createEvent === 'function'
) { ) {
const fakeNode = document.createElement('react'); const fakeNode = document.createElement('react');
@ -122,6 +124,7 @@ if (__DEV__) {
// Create an event handler for our fake event. We will synchronously // Create an event handler for our fake event. We will synchronously
// dispatch our fake event using `dispatchEvent`. Inside the handler, we // dispatch our fake event using `dispatchEvent`. Inside the handler, we
// call the user-provided callback. // call the user-provided callback.
// $FlowFixMe[method-unbinding]
const funcArgs = Array.prototype.slice.call(arguments, 3); const funcArgs = Array.prototype.slice.call(arguments, 3);
function callCallback() { function callCallback() {
didCall = true; didCall = true;

View File

@ -47,4 +47,4 @@ munge_underscores=false
%REACT_RENDERER_FLOW_OPTIONS% %REACT_RENDERER_FLOW_OPTIONS%
[version] [version]
^0.152.0 ^0.153.0

View File

@ -7912,10 +7912,10 @@ flatted@^2.0.0:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138"
integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==
flow-bin@^0.152.0: flow-bin@^0.153.0:
version "0.152.0" version "0.153.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.152.0.tgz#6980d0cd58f59e9aefd580b11109a1d56eba46b1" resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.153.0.tgz#44d941acaf5ef977fa26d1b4b5dc3cf56b68eefc"
integrity sha512-b4ijbZIQovcx5l/T7VnwyBPIikj60A2qk7hKqQKVWiuftQMrUmC5ct2/0SuVvheX6ZbPdZfeyw2EHO1/n3eAmw== integrity sha512-sxP9nfXnoyCUT6hjAO+zDyHLO3dZcWg0h+4HttHs/5wg/2oAkTDwmsWbj095IQsEmwTicq2TfqWq5QRuLxynlQ==
fluent-syntax@0.13.0: fluent-syntax@0.13.0:
version "0.13.0" version "0.13.0"