diff --git a/packages/react-client/src/ReactFlightClient.js b/packages/react-client/src/ReactFlightClient.js index d6ae368abf12c..584639921e510 100644 --- a/packages/react-client/src/ReactFlightClient.js +++ b/packages/react-client/src/ReactFlightClient.js @@ -34,7 +34,7 @@ export type JSONValue = | null | boolean | string - | {+[key: string]: JSONValue} + | {|+[key: string]: JSONValue|} | $ReadOnlyArray; const PENDING = 0; @@ -43,36 +43,36 @@ const RESOLVED_MODULE = 2; const INITIALIZED = 3; const ERRORED = 4; -type PendingChunk = { +type PendingChunk = {| _status: 0, _value: null | Array<() => mixed>, _response: Response, then(resolve: () => mixed): void, -}; -type ResolvedModelChunk = { +|}; +type ResolvedModelChunk = {| _status: 1, _value: UninitializedModel, _response: Response, then(resolve: () => mixed): void, -}; -type ResolvedModuleChunk = { +|}; +type ResolvedModuleChunk = {| _status: 2, _value: ModuleReference, _response: Response, then(resolve: () => mixed): void, -}; -type InitializedChunk = { +|}; +type InitializedChunk = {| _status: 3, _value: T, _response: Response, then(resolve: () => mixed): void, -}; -type ErroredChunk = { +|}; +type ErroredChunk = {| _status: 4, _value: Error, _response: Response, then(resolve: () => mixed): void, -}; +|}; type SomeChunk = | PendingChunk | ResolvedModelChunk @@ -129,10 +129,12 @@ function readRoot(): T { } function createPendingChunk(response: Response): PendingChunk { + // $FlowFixMe Flow doesn't support functions as constructors return new Chunk(PENDING, null, response); } function createErrorChunk(response: Response, error: Error): ErroredChunk { + // $FlowFixMe Flow doesn't support functions as constructors return new Chunk(ERRORED, error, response); } @@ -140,6 +142,7 @@ function createInitializedChunk( response: Response, value: T, ): InitializedChunk { + // $FlowFixMe Flow doesn't support functions as constructors return new Chunk(INITIALIZED, value, response); } @@ -168,6 +171,7 @@ function createResolvedModelChunk( response: Response, value: UninitializedModel, ): ResolvedModelChunk { + // $FlowFixMe Flow doesn't support functions as constructors return new Chunk(RESOLVED_MODEL, value, response); } @@ -175,6 +179,7 @@ function createResolvedModuleChunk( response: Response, value: ModuleReference, ): ResolvedModuleChunk { + // $FlowFixMe Flow doesn't support functions as constructors return new Chunk(RESOLVED_MODULE, value, response); } @@ -333,7 +338,7 @@ export function parseModelString( export function parseModelTuple( response: Response, - value: {+[key: string]: JSONValue} | $ReadOnlyArray, + value: {|+[key: string]: JSONValue|} | $ReadOnlyArray, ): any { const tuple: [mixed, mixed, mixed, mixed] = (value: any); diff --git a/packages/react-client/src/ReactFlightClientHostConfigStream.js b/packages/react-client/src/ReactFlightClientHostConfigStream.js index 2005e8a98a9ed..d56e5d43128fc 100644 --- a/packages/react-client/src/ReactFlightClientHostConfigStream.js +++ b/packages/react-client/src/ReactFlightClientHostConfigStream.js @@ -10,11 +10,11 @@ import type {ResponseBase} from './ReactFlightClient'; import type {StringDecoder} from './ReactFlightClientHostConfig'; -export type Response = ResponseBase & { +export type Response = ResponseBase & {| _partialRow: string, _fromJSON: (key: string, value: JSONValue) => any, _stringDecoder: StringDecoder, -}; +|}; export type UninitializedModel = string; diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js index 7cfb576fad378..68305e4a9369f 100644 --- a/packages/react-debug-tools/src/ReactDebugHooks.js +++ b/packages/react-debug-tools/src/ReactDebugHooks.js @@ -51,10 +51,10 @@ type Dispatch = A => void; let primitiveStackCache: null | Map> = null; -type Hook = { +type Hook = {| memoizedState: any, next: Hook | null, -}; +|}; function getPrimitiveStackCache(): Map> { // This initializes a cache of all primitive hooks so that the top @@ -371,12 +371,12 @@ const DispatcherProxy = new Proxy(Dispatcher, DispatcherProxyHandler); // Inspect -export type HookSource = { +export type HookSource = {| lineNumber: number | null, columnNumber: number | null, fileName: string | null, functionName: string | null, -}; +|}; export type HooksNode = { id: number | null, diff --git a/packages/react-devtools-shared/src/Logger.js b/packages/react-devtools-shared/src/Logger.js index ddf60f8fd70f7..6ddb40f0a97e2 100644 --- a/packages/react-devtools-shared/src/Logger.js +++ b/packages/react-devtools-shared/src/Logger.js @@ -34,24 +34,24 @@ export type LoggerEvent = |} | {| +event_name: 'select-element', - +metadata: { + +metadata: {| +source: string, - }, + |}, |} | {| +event_name: 'inspect-element-button-clicked', |} | {| +event_name: 'profiling-start', - +metadata: { + +metadata: {| +current_tab: string, - }, + |}, |} | {| +event_name: 'profiler-tab-changed', - +metadata: { + +metadata: {| +tabId: string, - }, + |}, |} | {| +event_name: 'settings-changed', diff --git a/packages/react-devtools-shared/src/backend/console.js b/packages/react-devtools-shared/src/backend/console.js index ee802f8ea47a1..03c36c14dcf79 100644 --- a/packages/react-devtools-shared/src/backend/console.js +++ b/packages/react-devtools-shared/src/backend/console.js @@ -151,13 +151,13 @@ export function patch({ showInlineWarningsAndErrors, hideConsoleLogsInStrictMode, browserTheme, -}: { +}: {| appendComponentStack: boolean, breakOnConsoleErrors: boolean, showInlineWarningsAndErrors: boolean, hideConsoleLogsInStrictMode: boolean, browserTheme: BrowserTheme, -}): void { +|}): void { // Settings may change after we've patched the console. // Using a shared ref allows the patch function to read the latest values. consoleSettingsRef.appendComponentStack = appendComponentStack; diff --git a/packages/react-devtools-shared/src/constants.js b/packages/react-devtools-shared/src/constants.js index 2406f4876d201..8853e46f24c17 100644 --- a/packages/react-devtools-shared/src/constants.js +++ b/packages/react-devtools-shared/src/constants.js @@ -79,7 +79,7 @@ import type { DisplayDensity, } from './devtools/views/Settings/SettingsContext'; -export const THEME_STYLES: {[style: Theme | DisplayDensity]: any} = { +export const THEME_STYLES: {[style: Theme | DisplayDensity]: any, ...} = { light: { '--color-attribute-name': '#ef6632', '--color-attribute-name-not-editable': '#23272f', diff --git a/packages/react-devtools-shared/src/devtools/ContextMenu/useContextMenu.js b/packages/react-devtools-shared/src/devtools/ContextMenu/useContextMenu.js index 150cb0766fc55..3493c55615706 100644 --- a/packages/react-devtools-shared/src/devtools/ContextMenu/useContextMenu.js +++ b/packages/react-devtools-shared/src/devtools/ContextMenu/useContextMenu.js @@ -22,7 +22,7 @@ export default function useContextMenu({ data: Object, id: string, onChange?: OnChangeFn, - ref: {current: ElementRef<*> | null}, + ref: {|current: ElementRef<*> | null|}, |}) { const {showMenu} = useContext(RegistryContext); diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementErrorsAndWarningsTree.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementErrorsAndWarningsTree.js index 7f7be4677e036..d45126c359f6f 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementErrorsAndWarningsTree.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementErrorsAndWarningsTree.js @@ -119,7 +119,7 @@ type TreeProps = {| badgeClassName: string, actions: React$Node, className: string, - clearMessages: () => {}, + clearMessages: () => void, entries: Array<[string, number]>, isTransitionPending: boolean, label: string, diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/HoveredFiberInfo.js b/packages/react-devtools-shared/src/devtools/views/Profiler/HoveredFiberInfo.js index 0dd5d67b2a164..cc3989c7b4a89 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/HoveredFiberInfo.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/HoveredFiberInfo.js @@ -23,9 +23,9 @@ export type TooltipFiberData = {| name: string, |}; -export type Props = { +export type Props = {| fiberData: ChartNode, -}; +|}; export default function HoveredFiberInfo({fiberData}: Props) { const {profilerStore} = useContext(StoreContext); diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitList.js b/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitList.js index 2b837f28f6495..56f62e01c5730 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitList.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitList.js @@ -82,11 +82,11 @@ type ListProps = {| width: number, |}; -type DragState = { +type DragState = {| commitIndex: number, left: number, sizeIncrement: number, -}; +|}; function List({ commitData, diff --git a/packages/react-devtools-shared/src/hook.js b/packages/react-devtools-shared/src/hook.js index 29cdea1e2b0b7..4ed128ba9df93 100644 --- a/packages/react-devtools-shared/src/hook.js +++ b/packages/react-devtools-shared/src/hook.js @@ -224,10 +224,10 @@ export function installHook(target: any): DevToolsHook | null { function patchConsoleForInitialRenderInStrictMode({ hideConsoleLogsInStrictMode, browserTheme, - }: { + }: {| hideConsoleLogsInStrictMode: boolean, browserTheme: BrowserTheme, - }) { + |}) { const overrideConsoleMethods = [ 'error', 'group', diff --git a/packages/react-devtools-shared/src/hooks/astUtils.js b/packages/react-devtools-shared/src/hooks/astUtils.js index 27db408c0500d..8d3c5e2fa2b0f 100644 --- a/packages/react-devtools-shared/src/hooks/astUtils.js +++ b/packages/react-devtools-shared/src/hooks/astUtils.js @@ -18,11 +18,11 @@ export type Position = {| column: number, |}; -export type SourceFileASTWithHookDetails = { +export type SourceFileASTWithHookDetails = {| sourceFileAST: File, line: number, source: string, -}; +|}; export const NO_HOOK_NAME = ''; diff --git a/packages/react-devtools-shared/src/inspectedElementCache.js b/packages/react-devtools-shared/src/inspectedElementCache.js index b7f08ffa523a1..b1f8204058480 100644 --- a/packages/react-devtools-shared/src/inspectedElementCache.js +++ b/packages/react-devtools-shared/src/inspectedElementCache.js @@ -168,12 +168,12 @@ export function checkForUpdate({ element, refresh, store, -}: { +}: {| bridge: FrontendBridge, element: Element, refresh: RefreshFunction, store: Store, -}): void { +|}): void { const {id} = element; const rendererID = store.getRendererIDForElement(id); if (rendererID != null) { diff --git a/packages/react-devtools-shared/src/node_modules/react-window/src/VariableSizeGrid.js b/packages/react-devtools-shared/src/node_modules/react-window/src/VariableSizeGrid.js index 46d59521f1978..2ce4f2d9a04ce 100644 --- a/packages/react-devtools-shared/src/node_modules/react-window/src/VariableSizeGrid.js +++ b/packages/react-devtools-shared/src/node_modules/react-window/src/VariableSizeGrid.js @@ -19,7 +19,7 @@ type ItemMetadata = {| offset: number, size: number, |}; -type ItemMetadataMap = { [index: number]: ItemMetadata }; +type ItemMetadataMap = { [index: number]: ItemMetadata, ... }; type InstanceProps = {| columnMetadataMap: ItemMetadataMap, estimatedColumnWidth: number, diff --git a/packages/react-devtools-shared/src/node_modules/react-window/src/VariableSizeList.js b/packages/react-devtools-shared/src/node_modules/react-window/src/VariableSizeList.js index f4ad103231017..887641b010eef 100644 --- a/packages/react-devtools-shared/src/node_modules/react-window/src/VariableSizeList.js +++ b/packages/react-devtools-shared/src/node_modules/react-window/src/VariableSizeList.js @@ -18,7 +18,7 @@ type ItemMetadata = {| size: number, |}; type InstanceProps = {| - itemMetadataMap: { [index: number]: ItemMetadata }, + itemMetadataMap: { [index: number]: ItemMetadata, ... }, estimatedItemSize: number, lastMeasuredIndex: number, |}; diff --git a/packages/react-devtools-timeline/src/CanvasPage.js b/packages/react-devtools-timeline/src/CanvasPage.js index 3abc8ea7a3999..273b67bed1709 100644 --- a/packages/react-devtools-timeline/src/CanvasPage.js +++ b/packages/react-devtools-timeline/src/CanvasPage.js @@ -80,7 +80,7 @@ function CanvasPage({profilerData, viewState}: Props) { className={styles.CanvasPage} style={{backgroundColor: COLORS.BACKGROUND}}> - {({height, width}: {height: number, width: number}) => ( + {({height, width}: {|height: number, width: number|}) => ( = Return_<*, T>; // Project types -export type ErrorStackFrame = { +export type ErrorStackFrame = {| fileName: string, lineNumber: number, columnNumber: number, -}; +|}; export type Milliseconds = number; diff --git a/packages/react-devtools-timeline/src/utils/useSmartTooltip.js b/packages/react-devtools-timeline/src/utils/useSmartTooltip.js index 16cdec365f611..2a36396b8fabc 100644 --- a/packages/react-devtools-timeline/src/utils/useSmartTooltip.js +++ b/packages/react-devtools-timeline/src/utils/useSmartTooltip.js @@ -16,11 +16,11 @@ export default function useSmartTooltip({ canvasRef, mouseX, mouseY, -}: { +}: {| canvasRef: {|current: HTMLCanvasElement | null|}, mouseX: number, mouseY: number, -}) { +|}) { const ref = useRef(null); // HACK: Browser extension reports window.innerHeight of 0, diff --git a/packages/react-devtools-timeline/src/view-base/resizable/ResizableView.js b/packages/react-devtools-timeline/src/view-base/resizable/ResizableView.js index b56422f715a52..36b8f201e4706 100644 --- a/packages/react-devtools-timeline/src/view-base/resizable/ResizableView.js +++ b/packages/react-devtools-timeline/src/view-base/resizable/ResizableView.js @@ -47,7 +47,7 @@ const HIDDEN_RECT = { }; export class ResizableView extends View { - _canvasRef: {current: HTMLCanvasElement | null}; + _canvasRef: {|current: HTMLCanvasElement | null|}; _layoutState: LayoutState; _mutableViewStateKey: string; _resizeBar: ResizeBarView; @@ -60,7 +60,7 @@ export class ResizableView extends View { frame: Rect, subview: View, viewState: ViewState, - canvasRef: {current: HTMLCanvasElement | null}, + canvasRef: {|current: HTMLCanvasElement | null|}, label: string, ) { super(surface, frame, noopLayout); diff --git a/packages/react-devtools-timeline/src/view-base/utils/scrollState.js b/packages/react-devtools-timeline/src/view-base/utils/scrollState.js index 9e9bdb4919f3f..8089c81e31928 100644 --- a/packages/react-devtools-timeline/src/view-base/utils/scrollState.js +++ b/packages/react-devtools-timeline/src/view-base/utils/scrollState.js @@ -35,12 +35,12 @@ function clampLength({ minContentLength, maxContentLength, containerLength, -}: { +}: {| state: ScrollState, minContentLength: number, maxContentLength: number, containerLength: number, -}): ScrollState { +|}): ScrollState { return { offset: state.offset, length: clamp( @@ -62,12 +62,12 @@ export function clampState({ minContentLength, maxContentLength, containerLength, -}: { +}: {| state: ScrollState, minContentLength: number, maxContentLength: number, containerLength: number, -}): ScrollState { +|}): ScrollState { return clampOffset( clampLength({ state, @@ -83,11 +83,11 @@ export function translateState({ state, delta, containerLength, -}: { +}: {| state: ScrollState, delta: number, containerLength: number, -}): ScrollState { +|}): ScrollState { return clampOffset( { offset: state.offset + delta, @@ -119,7 +119,7 @@ export function zoomState({ minContentLength, maxContentLength, containerLength, -}: { +}: {| state: ScrollState, multiplier: number, fixedPoint: number, @@ -127,7 +127,7 @@ export function zoomState({ minContentLength: number, maxContentLength: number, containerLength: number, -}): ScrollState { +|}): ScrollState { // Length and offset must be computed separately, so that if the length is // clamped the offset will still be correct (unless it gets clamped too). @@ -164,7 +164,7 @@ export function moveStateToRange({ minContentLength, maxContentLength, containerLength, -}: { +}: {| state: ScrollState, rangeStart: number, rangeEnd: number, @@ -173,7 +173,7 @@ export function moveStateToRange({ minContentLength: number, maxContentLength: number, containerLength: number, -}): ScrollState { +|}): ScrollState { // Length and offset must be computed separately, so that if the length is // clamped the offset will still be correct (unless it gets clamped too). diff --git a/packages/react-dom/src/client/ReactDOMHostConfig.js b/packages/react-dom/src/client/ReactDOMHostConfig.js index 52646306767ce..11f527ad583df 100644 --- a/packages/react-dom/src/client/ReactDOMHostConfig.js +++ b/packages/react-dom/src/client/ReactDOMHostConfig.js @@ -733,7 +733,7 @@ export function isSuspenseInstanceFallback(instance: SuspenseInstance) { export function getSuspenseInstanceFallbackErrorDetails( instance: SuspenseInstance, -): {digest: ?string, message?: string, stack?: string} { +): {|digest: ?string, message?: string, stack?: string|} { const dataset = instance.nextSibling && ((instance.nextSibling: any): HTMLElement).dataset; let digest, message, stack; @@ -1320,10 +1320,10 @@ export function setFocusIfFocusable(node: Instance): boolean { return didFocus; } -type RectRatio = { +type RectRatio = {| ratio: number, rect: BoundingRect, -}; +|}; export function setupIntersectionObserver( targets: Array, diff --git a/packages/react-dom/src/events/ReactSyntheticEventType.js b/packages/react-dom/src/events/ReactSyntheticEventType.js index d92777a75cce3..92ab3f94c5846 100644 --- a/packages/react-dom/src/events/ReactSyntheticEventType.js +++ b/packages/react-dom/src/events/ReactSyntheticEventType.js @@ -20,7 +20,7 @@ export type DispatchConfig = {| registrationName?: string, |}; -type BaseSyntheticEvent = { +type BaseSyntheticEvent = {| isPersistent: () => boolean, isPropagationStopped: () => boolean, _dispatchInstances?: null | Array | Fiber, @@ -31,14 +31,14 @@ type BaseSyntheticEvent = { relatedTarget?: mixed, type: string, currentTarget: null | EventTarget, -}; +|}; -export type KnownReactSyntheticEvent = BaseSyntheticEvent & { +export type KnownReactSyntheticEvent = BaseSyntheticEvent & {| _reactName: string, -}; -export type UnknownReactSyntheticEvent = BaseSyntheticEvent & { +|}; +export type UnknownReactSyntheticEvent = BaseSyntheticEvent & {| _reactName: null, -}; +|}; export type ReactSyntheticEvent = | KnownReactSyntheticEvent diff --git a/packages/react-dom/src/events/SyntheticEvent.js b/packages/react-dom/src/events/SyntheticEvent.js index 2c61b9a42ec23..0da906d712890 100644 --- a/packages/react-dom/src/events/SyntheticEvent.js +++ b/packages/react-dom/src/events/SyntheticEvent.js @@ -13,7 +13,8 @@ import assign from 'shared/assign'; import getEventCharCode from './getEventCharCode'; type EventInterfaceType = { - [propName: string]: 0 | ((event: {[propName: string]: mixed}) => mixed), + [propName: string]: 0 | ((event: {[propName: string]: mixed, ...}) => mixed), + ..., }; function functionThatReturnsTrue() { @@ -44,7 +45,7 @@ function createSyntheticEvent(Interface: EventInterfaceType) { reactName: string | null, reactEventType: string, targetInst: Fiber, - nativeEvent: {[propName: string]: mixed}, + nativeEvent: {[propName: string]: mixed, ...}, nativeEventTarget: null | EventTarget, ) { this._reactName = reactName; diff --git a/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js b/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js index 25920232e8710..953c31602f496 100644 --- a/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js +++ b/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js @@ -37,9 +37,9 @@ type Options = {| |}; // TODO: Move to sub-classing ReadableStream. -type ReactDOMServerReadableStream = ReadableStream & { +type ReactDOMServerReadableStream = ReadableStream & {| allReady: Promise, -}; +|}; function renderToReadableStream( children: ReactNodeList, diff --git a/packages/react-dom/src/server/ReactDOMLegacyServerBrowser.js b/packages/react-dom/src/server/ReactDOMLegacyServerBrowser.js index 71786e4b5078f..f1ca01de6b711 100644 --- a/packages/react-dom/src/server/ReactDOMLegacyServerBrowser.js +++ b/packages/react-dom/src/server/ReactDOMLegacyServerBrowser.js @@ -11,9 +11,9 @@ import type {ReactNodeList} from 'shared/ReactTypes'; import {version, renderToStringImpl} from './ReactDOMLegacyServerImpl'; -type ServerOptions = { +type ServerOptions = {| identifierPrefix?: string, -}; +|}; function renderToString( children: ReactNodeList, diff --git a/packages/react-dom/src/server/ReactDOMLegacyServerImpl.js b/packages/react-dom/src/server/ReactDOMLegacyServerImpl.js index 504201f3c24ff..acb0a3c1c04f1 100644 --- a/packages/react-dom/src/server/ReactDOMLegacyServerImpl.js +++ b/packages/react-dom/src/server/ReactDOMLegacyServerImpl.js @@ -23,9 +23,9 @@ import { createRootFormatContext, } from './ReactDOMServerLegacyFormatConfig'; -type ServerOptions = { +type ServerOptions = {| identifierPrefix?: string, -}; +|}; function onError() { // Non-fatal errors are ignored. diff --git a/packages/react-dom/src/server/ReactDOMLegacyServerNode.js b/packages/react-dom/src/server/ReactDOMLegacyServerNode.js index 20e89de8b430e..7c38c23101dce 100644 --- a/packages/react-dom/src/server/ReactDOMLegacyServerNode.js +++ b/packages/react-dom/src/server/ReactDOMLegacyServerNode.js @@ -15,9 +15,9 @@ import { renderToStaticNodeStream, } from './ReactDOMLegacyServerNodeStream'; -type ServerOptions = { +type ServerOptions = {| identifierPrefix?: string, -}; +|}; function renderToString( children: ReactNodeList, diff --git a/packages/react-dom/src/server/ReactDOMLegacyServerNodeStream.js b/packages/react-dom/src/server/ReactDOMLegacyServerNodeStream.js index 25b88156e0755..28bfadd240b33 100644 --- a/packages/react-dom/src/server/ReactDOMLegacyServerNodeStream.js +++ b/packages/react-dom/src/server/ReactDOMLegacyServerNodeStream.js @@ -25,9 +25,9 @@ import { import {Readable} from 'stream'; -type ServerOptions = { +type ServerOptions = {| identifierPrefix?: string, -}; +|}; class ReactMarkupReadableStream extends Readable { request: Request; diff --git a/packages/react-dom/src/server/ReactDOMServerFormatConfig.js b/packages/react-dom/src/server/ReactDOMServerFormatConfig.js index c30d9673265c2..b24edf264c6fc 100644 --- a/packages/react-dom/src/server/ReactDOMServerFormatConfig.js +++ b/packages/react-dom/src/server/ReactDOMServerFormatConfig.js @@ -105,10 +105,10 @@ const scriptRegex = /(<\/|<)(s)(cript)/gi; const scriptReplacer = (match, prefix, s, suffix) => `${prefix}${s === 's' ? '\\u0073' : '\\u0053'}${suffix}`; -export type BootstrapScriptDescriptor = { +export type BootstrapScriptDescriptor = {| src: string, integrity?: string, -}; +|}; // Allows us to keep track of what we've already written so we can refer back to it. export function createResponseState( identifierPrefix: string | void, @@ -203,10 +203,10 @@ const HTML_COLGROUP_MODE = 7; type InsertionMode = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7; // Lets us keep track of contextual state and pick it back up after suspending. -export type FormatContext = { +export type FormatContext = {| insertionMode: InsertionMode, // root/svg/html/mathml/table selectedValue: null | string | Array, // the selected value(s) inside a -}; +|}; function createFormatContext( insertionMode: InsertionMode, diff --git a/packages/react-dom/src/server/ReactDOMServerLegacyFormatConfig.js b/packages/react-dom/src/server/ReactDOMServerLegacyFormatConfig.js index 375562e80b56d..29a4793c963bd 100644 --- a/packages/react-dom/src/server/ReactDOMServerLegacyFormatConfig.js +++ b/packages/react-dom/src/server/ReactDOMServerLegacyFormatConfig.js @@ -28,7 +28,7 @@ import type { export const isPrimaryRenderer = false; -export type ResponseState = { +export type ResponseState = {| // Keep this in sync with ReactDOMServerFormatConfig bootstrapChunks: Array, startInlineScript: PrecomputedChunk, @@ -42,7 +42,7 @@ export type ResponseState = { sentClientRenderFunction: boolean, // This is an extra field for the legacy renderer generateStaticMarkup: boolean, -}; +|}; export function createResponseState( generateStaticMarkup: boolean, diff --git a/packages/react-fs/src/ReactFilesystem.js b/packages/react-fs/src/ReactFilesystem.js index e505005e21db2..acbe599010a96 100644 --- a/packages/react-fs/src/ReactFilesystem.js +++ b/packages/react-fs/src/ReactFilesystem.js @@ -128,7 +128,7 @@ function createLstatMap(): Map>> { return new Map(); } -export function lstat(path: string, options?: {bigint?: boolean}): mixed { +export function lstat(path: string, options?: {|bigint?: boolean|}): mixed { checkPathInDev(path); let bigint = false; if (options && options.bigint) { @@ -167,7 +167,7 @@ function createReaddirMap(): Map< export function readdir( path: string, - options?: string | {encoding?: string, withFileTypes?: boolean}, + options?: string | {|encoding?: string, withFileTypes?: boolean|}, ): mixed { checkPathInDev(path); let encoding = 'utf8'; @@ -215,12 +215,12 @@ export function readFile( path: string, options: | string - | { + | {| encoding?: string | null, // Unsupported: flag?: string, // Doesn't make sense except "r" signal?: mixed, // We'll have our own signal - }, + |}, ): string | Buffer { checkPathInDev(path); const map = unstable_getCacheForType(createReadFileMap); @@ -270,7 +270,7 @@ function createReadlinkMap(): Map>> { export function readlink( path: string, - options?: string | {encoding?: string}, + options?: string | {|encoding?: string|}, ): mixed { checkPathInDev(path); let encoding = 'utf8'; @@ -311,7 +311,7 @@ function createRealpathMap(): Map>> { export function realpath( path: string, - options?: string | {encoding?: string}, + options?: string | {|encoding?: string|}, ): mixed { checkPathInDev(path); let encoding = 'utf8'; @@ -350,7 +350,7 @@ function createStatMap(): Map>> { return new Map(); } -export function stat(path: string, options?: {bigint?: boolean}): mixed { +export function stat(path: string, options?: {|bigint?: boolean|}): mixed { checkPathInDev(path); let bigint = false; if (options && options.bigint) { diff --git a/packages/react-interactions/events/src/dom/create-event-handle/Focus.js b/packages/react-interactions/events/src/dom/create-event-handle/Focus.js index 19b0b9cbee401..4f988293db93c 100644 --- a/packages/react-interactions/events/src/dom/create-event-handle/Focus.js +++ b/packages/react-interactions/events/src/dom/create-event-handle/Focus.js @@ -14,15 +14,15 @@ const {useCallback, useEffect, useLayoutEffect, useRef} = React; type FocusEvent = SyntheticEvent; -type UseFocusOptions = { +type UseFocusOptions = {| disabled?: boolean, onBlur?: ?(FocusEvent) => void, onFocus?: ?(FocusEvent) => void, onFocusChange?: ?(boolean) => void, onFocusVisibleChange?: ?(boolean) => void, -}; +|}; -type UseFocusWithinOptions = { +type UseFocusWithinOptions = {| disabled?: boolean, onAfterBlurWithin?: FocusEvent => void, onBeforeBlurWithin?: FocusEvent => void, @@ -30,7 +30,7 @@ type UseFocusWithinOptions = { onFocusWithin?: FocusEvent => void, onFocusWithinChange?: boolean => void, onFocusWithinVisibleChange?: boolean => void, -}; +|}; const isMac = typeof window !== 'undefined' && window.navigator != null @@ -154,7 +154,7 @@ function useFocusLifecycles() { } export function useFocus( - focusTargetRef: {current: null | Node}, + focusTargetRef: {|current: null | Node|}, { disabled, onBlur, @@ -164,9 +164,10 @@ export function useFocus( }: UseFocusOptions, ): void { // Setup controlled state for this useFocus hook - const stateRef = useRef( - {isFocused: false, isFocusVisible: false}, - ); + const stateRef = useRef({isFocused: false, isFocusVisible: false}); const focusHandle = useEvent('focusin'); const blurHandle = useEvent('focusout'); const focusVisibleHandles = useFocusVisibleInputHandles(); @@ -248,7 +249,7 @@ export function useFocus( export function useFocusWithin( focusWithinTargetRef: - | {current: null | T} + | {|current: null | T|} | ((focusWithinTarget: null | T) => void), { disabled, @@ -261,9 +262,10 @@ export function useFocusWithin( }: UseFocusWithinOptions, ): (focusWithinTarget: null | T) => void { // Setup controlled state for this useFocus hook - const stateRef = useRef( - {isFocused: false, isFocusVisible: false}, - ); + const stateRef = useRef({isFocused: false, isFocusVisible: false}); const focusHandle = useEvent('focusin'); const blurHandle = useEvent('focusout'); const afterBlurHandle = useEvent('afterblur'); diff --git a/packages/react-native-renderer/src/ReactFabricHostConfig.js b/packages/react-native-renderer/src/ReactFabricHostConfig.js index c5c029006578f..febd24aaf3c90 100644 --- a/packages/react-native-renderer/src/ReactFabricHostConfig.js +++ b/packages/react-native-renderer/src/ReactFabricHostConfig.js @@ -108,13 +108,13 @@ export type EventListenerRemoveOptions = $ReadOnly<{| // TODO?: this will be changed in the future to be w3c-compatible and allow "EventListener" objects as well as functions. export type EventListener = Function; -type InternalEventListeners = { +type InternalEventListeners = {| [string]: {| listener: EventListener, options: EventListenerOptions, invalidated: boolean, |}[], -}; +|}; // TODO: Remove this conditional once all changes have propagated. if (registerEventHandler) { @@ -255,6 +255,8 @@ class ReactFabricHostComponent { const passive = optionsObj.passive || false; const signal = null; // TODO: implement signal/AbortSignal + /* $FlowFixMe the old version of Flow doesn't have a good way to define an + * empty exact object. */ const eventListeners: InternalEventListeners = this._eventListeners || {}; if (this._eventListeners == null) { this._eventListeners = eventListeners; diff --git a/packages/react-native-renderer/src/ReactNativeTypes.js b/packages/react-native-renderer/src/ReactNativeTypes.js index 4d2fdcc6afc3b..30583e45ae852 100644 --- a/packages/react-native-renderer/src/ReactNativeTypes.js +++ b/packages/react-native-renderer/src/ReactNativeTypes.js @@ -62,38 +62,38 @@ export type PartialAttributeConfiguration = $ReadOnly<{ ... }>; -export type ViewConfig = $ReadOnly<{ +export type ViewConfig = $ReadOnly<{| Commands?: $ReadOnly<{[commandName: string]: number, ...}>, Constants?: $ReadOnly<{[name: string]: mixed, ...}>, Manager?: string, NativeProps?: $ReadOnly<{[propName: string]: string, ...}>, baseModuleName?: ?string, bubblingEventTypes?: $ReadOnly<{ - [eventName: string]: $ReadOnly<{ - phasedRegistrationNames: $ReadOnly<{ + [eventName: string]: $ReadOnly<{| + phasedRegistrationNames: $ReadOnly<{| captured: string, bubbled: string, skipBubbling?: ?boolean, - }>, - }>, + |}>, + |}>, ..., }>, directEventTypes?: $ReadOnly<{ - [eventName: string]: $ReadOnly<{ + [eventName: string]: $ReadOnly<{| registrationName: string, - }>, + |}>, ..., }>, uiViewClassName: string, validAttributes: AttributeConfiguration, -}>; +|}>; -export type PartialViewConfig = $ReadOnly<{ +export type PartialViewConfig = $ReadOnly<{| bubblingEventTypes?: $PropertyType, directEventTypes?: $PropertyType, uiViewClassName: string, validAttributes?: PartialAttributeConfiguration, -}>; +|}>; export type NativeMethods = $ReadOnly<{| blur(): void, diff --git a/packages/react-native-renderer/src/legacy-events/PluginModuleType.js b/packages/react-native-renderer/src/legacy-events/PluginModuleType.js index 9488629dca6dd..5790a10dcf152 100644 --- a/packages/react-native-renderer/src/legacy-events/PluginModuleType.js +++ b/packages/react-native-renderer/src/legacy-events/PluginModuleType.js @@ -22,7 +22,7 @@ export type PluginName = string; export type EventSystemFlags = number; -export type LegacyPluginModule = { +export type LegacyPluginModule = {| eventTypes: EventTypes, extractEvents: ( topLevelType: TopLevelType, @@ -33,4 +33,4 @@ export type LegacyPluginModule = { container?: null | EventTarget, ) => ?ReactSyntheticEvent, tapMoveThreshold?: number, -}; +|}; diff --git a/packages/react-native-renderer/src/server/ReactNativeServerFormatConfig.js b/packages/react-native-renderer/src/server/ReactNativeServerFormatConfig.js index 92685d4f85bef..cb86b4628a174 100644 --- a/packages/react-native-renderer/src/server/ReactNativeServerFormatConfig.js +++ b/packages/react-native-renderer/src/server/ReactNativeServerFormatConfig.js @@ -58,9 +58,9 @@ const SUSPENSE_UPDATE_TO_CLIENT_RENDER = new Uint8Array(1); SUSPENSE_UPDATE_TO_CLIENT_RENDER[0] = SUSPENSE_UPDATE_TO_CLIENT_RENDER_TAG; // Per response, -export type ResponseState = { +export type ResponseState = {| nextSuspenseID: number, -}; +|}; // Allows us to keep track of what we've already written so we can refer back to it. export function createResponseState(): ResponseState { diff --git a/packages/react-reconciler/src/ReactFiberConcurrentUpdates.new.js b/packages/react-reconciler/src/ReactFiberConcurrentUpdates.new.js index e496389782025..0416cc28bbee2 100644 --- a/packages/react-reconciler/src/ReactFiberConcurrentUpdates.new.js +++ b/packages/react-reconciler/src/ReactFiberConcurrentUpdates.new.js @@ -33,14 +33,14 @@ import {NoFlags, Placement, Hydrating} from './ReactFiberFlags'; import {HostRoot, OffscreenComponent} from './ReactWorkTags'; import {OffscreenVisible} from './ReactFiberOffscreenComponent'; -export type ConcurrentUpdate = { +export type ConcurrentUpdate = {| next: ConcurrentUpdate, lane: Lane, -}; +|}; -type ConcurrentQueue = { +type ConcurrentQueue = {| pending: ConcurrentUpdate | null, -}; +|}; // If a render is in progress, and we receive an update from a concurrent event, // we wait until the current render is over (either finished or interrupted) diff --git a/packages/react-reconciler/src/ReactFiberConcurrentUpdates.old.js b/packages/react-reconciler/src/ReactFiberConcurrentUpdates.old.js index 7dd87358cf6a1..5ad81a8ff3f30 100644 --- a/packages/react-reconciler/src/ReactFiberConcurrentUpdates.old.js +++ b/packages/react-reconciler/src/ReactFiberConcurrentUpdates.old.js @@ -33,14 +33,14 @@ import {NoFlags, Placement, Hydrating} from './ReactFiberFlags'; import {HostRoot, OffscreenComponent} from './ReactWorkTags'; import {OffscreenVisible} from './ReactFiberOffscreenComponent'; -export type ConcurrentUpdate = { +export type ConcurrentUpdate = {| next: ConcurrentUpdate, lane: Lane, -}; +|}; -type ConcurrentQueue = { +type ConcurrentQueue = {| pending: ConcurrentUpdate | null, -}; +|}; // If a render is in progress, and we receive an update from a concurrent event, // we wait until the current render is over (either finished or interrupted) diff --git a/packages/react-reconciler/src/ReactFiberHiddenContext.new.js b/packages/react-reconciler/src/ReactFiberHiddenContext.new.js index 6f6309d6edb94..3ce3490a3990e 100644 --- a/packages/react-reconciler/src/ReactFiberHiddenContext.new.js +++ b/packages/react-reconciler/src/ReactFiberHiddenContext.new.js @@ -22,6 +22,7 @@ type HiddenContext = { // order to reveal the hidden content. // TODO: Remove `subtreeLanes` context from work loop in favor of this one. baseLanes: number, + ... }; // TODO: This isn't being used yet, but it's intended to replace the diff --git a/packages/react-reconciler/src/ReactFiberHiddenContext.old.js b/packages/react-reconciler/src/ReactFiberHiddenContext.old.js index c62fa3d12fa81..565dc4ae20e9f 100644 --- a/packages/react-reconciler/src/ReactFiberHiddenContext.old.js +++ b/packages/react-reconciler/src/ReactFiberHiddenContext.old.js @@ -22,6 +22,7 @@ type HiddenContext = { // order to reveal the hidden content. // TODO: Remove `subtreeLanes` context from work loop in favor of this one. baseLanes: number, + ... }; // TODO: This isn't being used yet, but it's intended to replace the diff --git a/packages/react-reconciler/src/ReactFiberHooks.new.js b/packages/react-reconciler/src/ReactFiberHooks.new.js index 87a65254b40fd..ee3d118a4a5a7 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.new.js +++ b/packages/react-reconciler/src/ReactFiberHooks.new.js @@ -1032,10 +1032,10 @@ function rerenderReducer( } type MutableSourceMemoizedState = {| - refs: { + refs: {| getSnapshot: MutableSourceGetSnapshotFn, setSnapshot: Snapshot => void, - }, + |}, source: MutableSource, subscribe: MutableSourceSubscribeFn, |}; diff --git a/packages/react-reconciler/src/ReactFiberHooks.old.js b/packages/react-reconciler/src/ReactFiberHooks.old.js index fd081fe5b0a68..aaa5ed306e42c 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.old.js +++ b/packages/react-reconciler/src/ReactFiberHooks.old.js @@ -1032,10 +1032,10 @@ function rerenderReducer( } type MutableSourceMemoizedState = {| - refs: { + refs: {| getSnapshot: MutableSourceGetSnapshotFn, setSnapshot: Snapshot => void, - }, + |}, source: MutableSource, subscribe: MutableSourceSubscribeFn, |}; diff --git a/packages/react-reconciler/src/ReactFiberRoot.new.js b/packages/react-reconciler/src/ReactFiberRoot.new.js index beaa5f509bc95..6482f560c8369 100644 --- a/packages/react-reconciler/src/ReactFiberRoot.new.js +++ b/packages/react-reconciler/src/ReactFiberRoot.new.js @@ -38,11 +38,11 @@ import {initializeUpdateQueue} from './ReactFiberClassUpdateQueue.new'; import {LegacyRoot, ConcurrentRoot} from './ReactRootTags'; import {createCache, retainCache} from './ReactFiberCacheComponent.new'; -export type RootState = { +export type RootState = {| element: any, isDehydrated: boolean, cache: Cache, -}; +|}; function FiberRootNode( containerInfo, diff --git a/packages/react-reconciler/src/ReactFiberRoot.old.js b/packages/react-reconciler/src/ReactFiberRoot.old.js index 11221f86a8f4c..0128418fdd47e 100644 --- a/packages/react-reconciler/src/ReactFiberRoot.old.js +++ b/packages/react-reconciler/src/ReactFiberRoot.old.js @@ -38,11 +38,11 @@ import {initializeUpdateQueue} from './ReactFiberClassUpdateQueue.old'; import {LegacyRoot, ConcurrentRoot} from './ReactRootTags'; import {createCache, retainCache} from './ReactFiberCacheComponent.old'; -export type RootState = { +export type RootState = {| element: any, isDehydrated: boolean, cache: Cache, -}; +|}; function FiberRootNode( containerInfo, diff --git a/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.new.js b/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.new.js index 1be1e7f930994..9c96e6646cccf 100644 --- a/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.new.js +++ b/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.new.js @@ -19,33 +19,33 @@ import {enableTransitionTracing} from 'shared/ReactFeatureFlags'; import {createCursor, push, pop} from './ReactFiberStack.new'; import {getWorkInProgressTransitions} from './ReactFiberWorkLoop.new'; -export type SuspenseInfo = {name: string | null}; +export type SuspenseInfo = {|name: string | null|}; -export type PendingTransitionCallbacks = { +export type PendingTransitionCallbacks = {| transitionStart: Array | null, transitionProgress: Map | null, transitionComplete: Array | null, markerProgress: Map< string, - {pendingBoundaries: PendingBoundaries, transitions: Set}, + {|pendingBoundaries: PendingBoundaries, transitions: Set|}, > | null, markerIncomplete: Map< string, - {aborts: Array, transitions: Set}, + {|aborts: Array, transitions: Set|}, > | null, markerComplete: Map> | null, -}; +|}; -export type Transition = { +export type Transition = {| name: string, startTime: number, -}; +|}; -export type BatchConfigTransition = { +export type BatchConfigTransition = {| name?: string, startTime?: number, _updatedFibers?: Set, -}; +|}; // TODO: Is there a way to not include the tag or name here? export type TracingMarkerInstance = {| diff --git a/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.old.js b/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.old.js index e88930867851a..939a1ae0432d5 100644 --- a/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.old.js +++ b/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.old.js @@ -19,33 +19,33 @@ import {enableTransitionTracing} from 'shared/ReactFeatureFlags'; import {createCursor, push, pop} from './ReactFiberStack.old'; import {getWorkInProgressTransitions} from './ReactFiberWorkLoop.old'; -export type SuspenseInfo = {name: string | null}; +export type SuspenseInfo = {|name: string | null|}; -export type PendingTransitionCallbacks = { +export type PendingTransitionCallbacks = {| transitionStart: Array | null, transitionProgress: Map | null, transitionComplete: Array | null, markerProgress: Map< string, - {pendingBoundaries: PendingBoundaries, transitions: Set}, + {|pendingBoundaries: PendingBoundaries, transitions: Set|}, > | null, markerIncomplete: Map< string, - {aborts: Array, transitions: Set}, + {|aborts: Array, transitions: Set|}, > | null, markerComplete: Map> | null, -}; +|}; -export type Transition = { +export type Transition = {| name: string, startTime: number, -}; +|}; -export type BatchConfigTransition = { +export type BatchConfigTransition = {| name?: string, startTime?: number, _updatedFibers?: Set, -}; +|}; // TODO: Is there a way to not include the tag or name here? export type TracingMarkerInstance = {| diff --git a/packages/react-reconciler/src/ReactFiberTreeContext.new.js b/packages/react-reconciler/src/ReactFiberTreeContext.new.js index f9c5104ed6b13..1a5305822be9a 100644 --- a/packages/react-reconciler/src/ReactFiberTreeContext.new.js +++ b/packages/react-reconciler/src/ReactFiberTreeContext.new.js @@ -64,10 +64,10 @@ import {getIsHydrating} from './ReactFiberHydrationContext.new'; import {clz32} from './clz32'; import {Forked, NoFlags} from './ReactFiberFlags'; -export type TreeContext = { +export type TreeContext = {| id: number, overflow: string, -}; +|}; // TODO: Use the unified fiber stack module instead of this local one? // Intentionally not using it yet to derisk the initial implementation, because diff --git a/packages/react-reconciler/src/ReactFiberTreeContext.old.js b/packages/react-reconciler/src/ReactFiberTreeContext.old.js index 840335d00c4e4..dabfe8fdb6f82 100644 --- a/packages/react-reconciler/src/ReactFiberTreeContext.old.js +++ b/packages/react-reconciler/src/ReactFiberTreeContext.old.js @@ -64,10 +64,10 @@ import {getIsHydrating} from './ReactFiberHydrationContext.old'; import {clz32} from './clz32'; import {Forked, NoFlags} from './ReactFiberFlags'; -export type TreeContext = { +export type TreeContext = {| id: number, overflow: string, -}; +|}; // TODO: Use the unified fiber stack module instead of this local one? // Intentionally not using it yet to derisk the initial implementation, because diff --git a/packages/react-reconciler/src/ReactInternalTypes.js b/packages/react-reconciler/src/ReactInternalTypes.js index c8239dc2483e0..5770adb76bcb8 100644 --- a/packages/react-reconciler/src/ReactInternalTypes.js +++ b/packages/react-reconciler/src/ReactInternalTypes.js @@ -258,7 +258,7 @@ type BaseFiberRootProperties = {| onRecoverableError: ( error: mixed, - errorInfo: {digest?: ?string, componentStack?: ?string}, + errorInfo: {|digest?: ?string, componentStack?: ?string|}, ) => void, |}; @@ -280,22 +280,22 @@ type SuspenseCallbackOnlyFiberRootProperties = {| hydrationCallbacks: null | SuspenseHydrationCallbacks, |}; -export type TransitionTracingCallbacks = { +export type TransitionTracingCallbacks = {| onTransitionStart?: (transitionName: string, startTime: number) => void, onTransitionProgress?: ( transitionName: string, startTime: number, currentTime: number, - pending: Array<{name: null | string}>, + pending: Array<{|name: null | string|}>, ) => void, onTransitionIncomplete?: ( transitionName: string, startTime: number, - deletions: Array<{ + deletions: Array<{| type: string, name?: string | null, endTime: number, - }>, + |}>, ) => void, onTransitionComplete?: ( transitionName: string, @@ -307,17 +307,17 @@ export type TransitionTracingCallbacks = { marker: string, startTime: number, currentTime: number, - pending: Array<{name: null | string}>, + pending: Array<{|name: null | string|}>, ) => void, onMarkerIncomplete?: ( transitionName: string, marker: string, startTime: number, - deletions: Array<{ + deletions: Array<{| type: string, name?: string | null, endTime: number, - }>, + |}>, ) => void, onMarkerComplete?: ( transitionName: string, @@ -325,7 +325,7 @@ export type TransitionTracingCallbacks = { startTime: number, endTime: number, ) => void, -}; +|}; // The following fields are only used in transition tracing in Profile builds type TransitionTracingOnlyFiberRootProperties = {| diff --git a/packages/react-reconciler/src/ReactTestSelectors.js b/packages/react-reconciler/src/ReactTestSelectors.js index ad1333c936147..3efe5ddadb3fd 100644 --- a/packages/react-reconciler/src/ReactTestSelectors.js +++ b/packages/react-reconciler/src/ReactTestSelectors.js @@ -506,13 +506,15 @@ export function onCommitRoot(): void { export type IntersectionObserverOptions = Object; export type ObserveVisibleRectsCallback = ( - intersections: Array<{ratio: number, rect: BoundingRect}>, + intersections: Array<{|ratio: number, rect: BoundingRect|}>, ) => void; export function observeVisibleRects( hostRoot: Instance, selectors: Array, - callback: (intersections: Array<{ratio: number, rect: BoundingRect}>) => void, + callback: ( + intersections: Array<{|ratio: number, rect: BoundingRect|}>, + ) => void, options?: IntersectionObserverOptions, ): {|disconnect: () => void|} { if (!supportsTestSelectors) { diff --git a/packages/react-server-dom-relay/src/ReactDOMServerFB.js b/packages/react-server-dom-relay/src/ReactDOMServerFB.js index 0d7aeef6cbd4f..b430beac2c505 100644 --- a/packages/react-server-dom-relay/src/ReactDOMServerFB.js +++ b/packages/react-server-dom-relay/src/ReactDOMServerFB.js @@ -26,19 +26,19 @@ import { createRootFormatContext, } from 'react-server/src/ReactServerFormatConfig'; -type Options = { +type Options = {| identifierPrefix?: string, bootstrapScriptContent?: string, bootstrapScripts: Array, bootstrapModules: Array, progressiveChunkSize?: number, onError: (error: mixed) => void, -}; +|}; -opaque type Stream = { +opaque type Stream = {| destination: Destination, request: Request, -}; +|}; function renderToStream(children: ReactNodeList, options: Options): Stream { const destination = { diff --git a/packages/react-server-dom-relay/src/ReactFlightDOMRelayClient.js b/packages/react-server-dom-relay/src/ReactFlightDOMRelayClient.js index 6ea0b861aa7a9..ece3124bcf80e 100644 --- a/packages/react-server-dom-relay/src/ReactFlightDOMRelayClient.js +++ b/packages/react-server-dom-relay/src/ReactFlightDOMRelayClient.js @@ -24,8 +24,10 @@ export {createResponse, close}; export function resolveRow(response: Response, chunk: RowEncoding): void { if (chunk[0] === 'J') { + // $FlowFixMe unable to refine on array indices resolveModel(response, chunk[1], chunk[2]); } else if (chunk[0] === 'M') { + // $FlowFixMe unable to refine on array indices resolveModule(response, chunk[1], chunk[2]); } else if (chunk[0] === 'S') { // $FlowFixMe: Flow doesn't support disjoint unions on tuples. diff --git a/packages/react-server-dom-relay/src/ReactFlightDOMRelayProtocol.js b/packages/react-server-dom-relay/src/ReactFlightDOMRelayProtocol.js index 60d19ecef3f78..0a2e99eb9baa8 100644 --- a/packages/react-server-dom-relay/src/ReactFlightDOMRelayProtocol.js +++ b/packages/react-server-dom-relay/src/ReactFlightDOMRelayProtocol.js @@ -14,8 +14,8 @@ export type JSONValue = | number | boolean | null - | {+[key: string]: JSONValue} - | Array; + | {|+[key: string]: JSONValue|} + | $ReadOnlyArray; export type RowEncoding = | ['J', number, JSONValue] diff --git a/packages/react-server-dom-relay/src/ReactFlightDOMRelayServer.js b/packages/react-server-dom-relay/src/ReactFlightDOMRelayServer.js index 5e65921193ba7..eb3c5fce2a839 100644 --- a/packages/react-server-dom-relay/src/ReactFlightDOMRelayServer.js +++ b/packages/react-server-dom-relay/src/ReactFlightDOMRelayServer.js @@ -19,10 +19,10 @@ import { startFlowing, } from 'react-server/src/ReactFlightServer'; -type Options = { +type Options = {| onError?: (error: mixed) => void, identifierPrefix?: string, -}; +|}; function render( model: ReactModel, diff --git a/packages/react-server-dom-relay/src/ReactFlightDOMRelayServerHostConfig.js b/packages/react-server-dom-relay/src/ReactFlightDOMRelayServerHostConfig.js index 0ec5b2cf0dc43..0b46fe2397ed2 100644 --- a/packages/react-server-dom-relay/src/ReactFlightDOMRelayServerHostConfig.js +++ b/packages/react-server-dom-relay/src/ReactFlightDOMRelayServerHostConfig.js @@ -78,7 +78,7 @@ export function processErrorChunk( function convertModelToJSON( request: Request, - parent: {+[key: string]: ReactModel} | $ReadOnlyArray, + parent: {|+[key: string]: ReactModel|} | $ReadOnlyArray, key: string, model: ReactModel, ): JSONValue { @@ -91,7 +91,9 @@ function convertModelToJSON( } return jsonArray; } else { - const jsonObj: {[key: string]: JSONValue} = {}; + /* $FlowFixMe the old version of Flow doesn't have a good way to define + * an empty exact object. */ + const jsonObj: {|[key: string]: JSONValue|} = {}; for (const nextKey in json) { if (hasOwnProperty.call(json, nextKey)) { jsonObj[nextKey] = convertModelToJSON( @@ -113,6 +115,7 @@ export function processModelChunk( id: number, model: ReactModel, ): Chunk { + // $FlowFixMe no good way to define an empty exact object const json = convertModelToJSON(request, {}, '', model); return ['J', id, json]; } @@ -159,6 +162,7 @@ export function flushBuffered(destination: Destination) {} export function beginWriting(destination: Destination) {} export function writeChunk(destination: Destination, chunk: Chunk): void { + // $FlowFixMe `Chunk` doesn't flow into `JSONValue` because of the `E` row type. emitRow(destination, chunk); } @@ -166,6 +170,7 @@ export function writeChunkAndReturn( destination: Destination, chunk: Chunk, ): boolean { + // $FlowFixMe `Chunk` doesn't flow into `JSONValue` because of the `E` row type. emitRow(destination, chunk); return true; } diff --git a/packages/react-server-dom-relay/src/ReactServerStreamConfigFB.js b/packages/react-server-dom-relay/src/ReactServerStreamConfigFB.js index d0de924db7cee..d26271ba15a80 100644 --- a/packages/react-server-dom-relay/src/ReactServerStreamConfigFB.js +++ b/packages/react-server-dom-relay/src/ReactServerStreamConfigFB.js @@ -7,12 +7,12 @@ * @flow */ -export type Destination = { +export type Destination = {| buffer: string, done: boolean, fatal: boolean, error: mixed, -}; +|}; export type PrecomputedChunk = string; export type Chunk = string; diff --git a/packages/react-server-dom-webpack/src/ReactFlightClientWebpackBundlerConfig.js b/packages/react-server-dom-webpack/src/ReactFlightClientWebpackBundlerConfig.js index 288f63bfdc92c..64bb2b986d70b 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightClientWebpackBundlerConfig.js +++ b/packages/react-server-dom-webpack/src/ReactFlightClientWebpackBundlerConfig.js @@ -9,20 +9,20 @@ import type {Thenable} from 'shared/ReactTypes'; -export type WebpackSSRMap = { - [clientId: string]: { +export type WebpackSSRMap = {| + [clientId: string]: {| [clientExportName: string]: ModuleMetaData, - }, -}; + |}, +|}; export type BundlerConfig = null | WebpackSSRMap; -export opaque type ModuleMetaData = { +export opaque type ModuleMetaData = {| id: string, chunks: Array, name: string, async: boolean, -}; +|}; // eslint-disable-next-line no-unused-vars export opaque type ModuleReference = ModuleMetaData; diff --git a/packages/react-server-dom-webpack/src/ReactFlightDOMClient.js b/packages/react-server-dom-webpack/src/ReactFlightDOMClient.js index 32f8e794f4f70..532e045787228 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightDOMClient.js +++ b/packages/react-server-dom-webpack/src/ReactFlightDOMClient.js @@ -19,9 +19,9 @@ import { close, } from 'react-client/src/ReactFlightClientStream'; -export type Options = { +export type Options = {| moduleMap?: BundlerConfig, -}; +|}; function startReadingFromStream( response: FlightResponse, diff --git a/packages/react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js b/packages/react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js index 2cbd609b473f2..8f4a52bacfceb 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js +++ b/packages/react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js @@ -18,12 +18,12 @@ import { abort, } from 'react-server/src/ReactFlightServer'; -type Options = { +type Options = {| identifierPrefix?: string, signal?: AbortSignal, context?: Array<[string, ServerContextJSONValue]>, onError?: (error: mixed) => void, -}; +|}; function renderToReadableStream( model: ReactModel, diff --git a/packages/react-server-dom-webpack/src/ReactFlightDOMServerNode.js b/packages/react-server-dom-webpack/src/ReactFlightDOMServerNode.js index 69fa772a304a9..c631f5b71a77f 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightDOMServerNode.js +++ b/packages/react-server-dom-webpack/src/ReactFlightDOMServerNode.js @@ -23,11 +23,11 @@ function createDrainHandler(destination, request) { return () => startFlowing(request, destination); } -type Options = { +type Options = {| onError?: (error: mixed) => void, context?: Array<[string, ServerContextJSONValue]>, identifierPrefix?: string, -}; +|}; type PipeableStream = {| abort(reason: mixed): void, diff --git a/packages/react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig.js b/packages/react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig.js index 8d7dccae333f2..79107b50316b0 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig.js +++ b/packages/react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig.js @@ -7,28 +7,28 @@ * @flow */ -type WebpackMap = { - [filepath: string]: { +type WebpackMap = {| + [filepath: string]: {| [name: string]: ModuleMetaData, - }, -}; + |}, +|}; export type BundlerConfig = WebpackMap; // eslint-disable-next-line no-unused-vars -export type ModuleReference = { +export type ModuleReference = {| $$typeof: symbol, filepath: string, name: string, async: boolean, -}; +|}; -export type ModuleMetaData = { +export type ModuleMetaData = {| id: string, chunks: Array, name: string, async: boolean, -}; +|}; export type ModuleKey = string; diff --git a/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js b/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js index 737a8502801bb..6ac08cad648b7 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js +++ b/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js @@ -9,37 +9,37 @@ import {acorn} from 'acorn'; -type ResolveContext = { +type ResolveContext = {| conditions: Array, parentURL: string | void, -}; +|}; type ResolveFunction = ( string, ResolveContext, ResolveFunction, -) => {url: string} | Promise<{url: string}>; +) => {|url: string|} | Promise<{|url: string|}>; -type GetSourceContext = { +type GetSourceContext = {| format: string, -}; +|}; type GetSourceFunction = ( string, GetSourceContext, GetSourceFunction, -) => Promise<{source: Source}>; +) => Promise<{|source: Source|}>; -type TransformSourceContext = { +type TransformSourceContext = {| format: string, url: string, -}; +|}; type TransformSourceFunction = ( Source, TransformSourceContext, TransformSourceFunction, -) => Promise<{source: Source}>; +) => Promise<{|source: Source|}>; type Source = string | ArrayBuffer | Uint8Array; @@ -52,7 +52,7 @@ export async function resolve( specifier: string, context: ResolveContext, defaultResolve: ResolveFunction, -): Promise<{url: string}> { +): Promise<{|url: string|}> { // We stash this in case we end up needing to resolve export * statements later. stashedResolve = defaultResolve; @@ -133,7 +133,7 @@ function addExportNames(names, node) { function resolveClientImport( specifier: string, parentURL: string, -): {url: string} | Promise<{url: string}> { +): {|url: string|} | Promise<{|url: string|}> { // Resolve an import specifier as if it was loaded by the client. This doesn't use // the overrides that this loader does but instead reverts to the default. // This resolution algorithm will not necessarily have the same configuration @@ -151,7 +151,7 @@ function resolveClientImport( async function loadClientImport( url: string, defaultTransformSource: TransformSourceFunction, -): Promise<{source: Source}> { +): Promise<{|source: Source|}> { if (stashedGetSource === null) { throw new Error( 'Expected getSource to have been called before transformSource', @@ -225,7 +225,7 @@ export async function transformSource( source: Source, context: TransformSourceContext, defaultTransformSource: TransformSourceFunction, -): Promise<{source: Source}> { +): Promise<{|source: Source|}> { const transformed = await defaultTransformSource( source, context, diff --git a/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js b/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js index 0c1ec39aff903..9c89122b04edc 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js +++ b/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js @@ -52,7 +52,7 @@ module.exports = function register() { // we should resolve that with a client reference that unwraps the Promise on // the client. const then = function then(resolve, reject) { - const moduleReference: {[string]: any} = { + const moduleReference: {[string]: any, ...} = { $$typeof: MODULE_REFERENCE, filepath: target.filepath, name: '*', // Represents the whole object instead of a particular import. @@ -93,7 +93,7 @@ module.exports = function register() { Module._extensions['.client.js'] = function(module, path) { const moduleId = url.pathToFileURL(path).href; - const moduleReference: {[string]: any} = { + const moduleReference: {[string]: any, ...} = { $$typeof: MODULE_REFERENCE, filepath: moduleId, name: '*', // Represents the whole object instead of a particular import. diff --git a/packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js b/packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js index b3da107e60b9c..7aa784a37f75f 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js +++ b/packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js @@ -42,21 +42,21 @@ class ClientReferenceDependency extends ModuleDependency { const clientImportName = 'react-server-dom-webpack'; const clientFileName = require.resolve('../'); -type ClientReferenceSearchPath = { +type ClientReferenceSearchPath = {| directory: string, recursive?: boolean, include: RegExp, exclude?: RegExp, -}; +|}; type ClientReferencePath = string | ClientReferenceSearchPath; -type Options = { +type Options = {| isServer: boolean, clientReferences?: ClientReferencePath | $ReadOnlyArray, chunkName?: string, manifestFilename?: string, -}; +|}; const PLUGIN_NAME = 'React Server Plugin'; diff --git a/packages/react-server-native-relay/src/ReactFlightNativeRelayClient.js b/packages/react-server-native-relay/src/ReactFlightNativeRelayClient.js index 42b9efa73b471..cea39ac6f2642 100644 --- a/packages/react-server-native-relay/src/ReactFlightNativeRelayClient.js +++ b/packages/react-server-native-relay/src/ReactFlightNativeRelayClient.js @@ -24,8 +24,10 @@ export {createResponse, close}; export function resolveRow(response: Response, chunk: RowEncoding): void { if (chunk[0] === 'J') { + // $FlowFixMe `Chunk` doesn't flow into `JSONValue` because of the `E` row type. resolveModel(response, chunk[1], chunk[2]); } else if (chunk[0] === 'M') { + // $FlowFixMe `Chunk` doesn't flow into `JSONValue` because of the `E` row type. resolveModule(response, chunk[1], chunk[2]); } else if (chunk[0] === 'S') { // $FlowFixMe: Flow doesn't support disjoint unions on tuples. diff --git a/packages/react-server-native-relay/src/ReactFlightNativeRelayProtocol.js b/packages/react-server-native-relay/src/ReactFlightNativeRelayProtocol.js index 1c32ac0dd4d44..ce10935859c8a 100644 --- a/packages/react-server-native-relay/src/ReactFlightNativeRelayProtocol.js +++ b/packages/react-server-native-relay/src/ReactFlightNativeRelayProtocol.js @@ -14,7 +14,7 @@ export type JSONValue = | number | boolean | null - | {+[key: string]: JSONValue} + | {|+[key: string]: JSONValue|} | Array; export type RowEncoding = diff --git a/packages/react-server-native-relay/src/ReactFlightNativeRelayServerHostConfig.js b/packages/react-server-native-relay/src/ReactFlightNativeRelayServerHostConfig.js index 5c9360701ab8d..581ba3de85e3a 100644 --- a/packages/react-server-native-relay/src/ReactFlightNativeRelayServerHostConfig.js +++ b/packages/react-server-native-relay/src/ReactFlightNativeRelayServerHostConfig.js @@ -75,7 +75,7 @@ export function processErrorChunk( function convertModelToJSON( request: Request, - parent: {+[key: string]: ReactModel} | $ReadOnlyArray, + parent: {|+[key: string]: ReactModel|} | $ReadOnlyArray, key: string, model: ReactModel, ): JSONValue { @@ -88,7 +88,8 @@ function convertModelToJSON( } return jsonArray; } else { - const jsonObj: {[key: string]: JSONValue} = {}; + // $FlowFixMe no good way to define an empty exact object + const jsonObj: {|[key: string]: JSONValue|} = {}; for (const nextKey in json) { if (hasOwnProperty.call(json, nextKey)) { jsonObj[nextKey] = convertModelToJSON( @@ -110,6 +111,7 @@ export function processModelChunk( id: number, model: ReactModel, ): Chunk { + // $FlowFixMe no good way to define an empty exact object const json = convertModelToJSON(request, {}, '', model); return ['J', id, json]; } @@ -156,6 +158,7 @@ export function flushBuffered(destination: Destination) {} export function beginWriting(destination: Destination) {} export function writeChunk(destination: Destination, chunk: Chunk): void { + // $FlowFixMe `Chunk` doesn't flow into `JSONValue` because of the `E` row type. emitRow(destination, chunk); } @@ -163,6 +166,7 @@ export function writeChunkAndReturn( destination: Destination, chunk: Chunk, ): boolean { + // $FlowFixMe `Chunk` doesn't flow into `JSONValue` because of the `E` row type. emitRow(destination, chunk); return true; } diff --git a/packages/react-server/src/ReactFizzClassComponent.js b/packages/react-server/src/ReactFizzClassComponent.js index 12fbeb46f2ded..9a17511dfc399 100644 --- a/packages/react-server/src/ReactFizzClassComponent.js +++ b/packages/react-server/src/ReactFizzClassComponent.js @@ -100,10 +100,10 @@ function warnNoop( } } -type InternalInstance = { +type InternalInstance = {| queue: null | Array, replace: boolean, -}; +|}; const classComponentUpdater = { isMounted(inst) { diff --git a/packages/react-server/src/ReactFizzComponentStack.js b/packages/react-server/src/ReactFizzComponentStack.js index 1fa49453d31b2..5a571af431269 100644 --- a/packages/react-server/src/ReactFizzComponentStack.js +++ b/packages/react-server/src/ReactFizzComponentStack.js @@ -14,21 +14,21 @@ import { } from 'shared/ReactComponentStackFrame'; // DEV-only reverse linked list representing the current component stack -type BuiltInComponentStackNode = { +type BuiltInComponentStackNode = {| tag: 0, parent: null | ComponentStackNode, type: string, -}; -type FunctionComponentStackNode = { +|}; +type FunctionComponentStackNode = {| tag: 1, parent: null | ComponentStackNode, type: Function, -}; -type ClassComponentStackNode = { +|}; +type ClassComponentStackNode = {| tag: 2, parent: null | ComponentStackNode, type: Function, -}; +|}; export type ComponentStackNode = | BuiltInComponentStackNode | FunctionComponentStackNode diff --git a/packages/react-server/src/ReactFizzNewContext.js b/packages/react-server/src/ReactFizzNewContext.js index b4386399c3340..fdd708748d63a 100644 --- a/packages/react-server/src/ReactFizzNewContext.js +++ b/packages/react-server/src/ReactFizzNewContext.js @@ -20,13 +20,13 @@ if (__DEV__) { // Used to store the parent path of all context overrides in a shared linked list. // Forming a reverse tree. -type ContextNode = { +type ContextNode = {| parent: null | ContextNode, depth: number, // Short hand to compute the depth of the tree at this node. context: ReactContext, parentValue: T, value: T, -}; +|}; // The structure of a context snapshot is an implementation of this file. // Currently, it's implemented as tracking the current active node. diff --git a/packages/react-server/src/ReactFizzServer.js b/packages/react-server/src/ReactFizzServer.js index 5f44458e7889c..f6cccbe4652d3 100644 --- a/packages/react-server/src/ReactFizzServer.js +++ b/packages/react-server/src/ReactFizzServer.js @@ -131,11 +131,11 @@ import {trackSuspendedWakeable} from './ReactFizzWakeable'; const ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; const ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; -type LegacyContext = { +type LegacyContext = {| [key: string]: any, -}; +|}; -type SuspenseBoundary = { +type SuspenseBoundary = {| id: SuspenseBoundaryID, rootSegmentID: number, errorDigest: ?string, // the error hash if it errors @@ -147,9 +147,9 @@ type SuspenseBoundary = { completedSegments: Array, // completed but not yet flushed segments. byteSize: number, // used to determine whether to inline children boundaries. fallbackAbortableTasks: Set, // used to cancel task on the fallback if the boundary completes or gets canceled. -}; +|}; -export type Task = { +export type Task = {| node: ReactNodeList, ping: () => void, blockedBoundary: Root | SuspenseBoundary, @@ -160,7 +160,7 @@ export type Task = { treeContext: TreeContext, // the current tree context that this task is executing in componentStack: null | ComponentStackNode, // DEV-only component stack thenableState: null | ThenableState, -}; +|}; const PENDING = 0; const COMPLETED = 1; @@ -170,7 +170,7 @@ const ERRORED = 4; type Root = null; -type Segment = { +type Segment = {| status: 0 | 1 | 2 | 3 | 4, parentFlushed: boolean, // typically a segment will be flushed by its parent, except if its parent was already flushed id: number, // starts as 0 and is lazily assigned if the parent flushes early @@ -184,13 +184,13 @@ type Segment = { // used to discern when text separator boundaries are needed lastPushedText: boolean, textEmbedded: boolean, -}; +|}; const OPEN = 0; const CLOSING = 1; const CLOSED = 2; -export opaque type Request = { +export opaque type Request = {| destination: null | Destination, +responseState: ResponseState, +progressiveChunkSize: number, @@ -223,7 +223,7 @@ export opaque type Request = { // emit a different response to the stream instead. onShellError: (error: mixed) => void, onFatalError: (error: mixed) => void, -}; +|}; // This is a default heuristic for how to split up the HTML content into progressive // loading. Our goal is to be able to display additional new content about every 500ms. diff --git a/packages/react-server/src/ReactFizzTreeContext.js b/packages/react-server/src/ReactFizzTreeContext.js index 3b924cf8eb3af..a06d3cf25d61f 100644 --- a/packages/react-server/src/ReactFizzTreeContext.js +++ b/packages/react-server/src/ReactFizzTreeContext.js @@ -60,10 +60,10 @@ // log2(32) = 5 bits. That means we can lop bits off the end 5 at a time without // affecting the final result. -export type TreeContext = { +export type TreeContext = {| +id: number, +overflow: string, -}; +|}; export const emptyTreeContext = { id: 1, diff --git a/packages/react-server/src/ReactFlightNewContext.js b/packages/react-server/src/ReactFlightNewContext.js index 3f5abaaf0793f..df6332a048b1c 100644 --- a/packages/react-server/src/ReactFlightNewContext.js +++ b/packages/react-server/src/ReactFlightNewContext.js @@ -23,13 +23,13 @@ if (__DEV__) { // Used to store the parent path of all context overrides in a shared linked list. // Forming a reverse tree. -type ContextNode = { +type ContextNode = {| parent: null | ContextNode, depth: number, // Short hand to compute the depth of the tree at this node. context: ReactServerContext, parentValue: T, value: T, -}; +|}; // The structure of a context snapshot is an implementation of this file. // Currently, it's implemented as tracking the current active node. diff --git a/packages/react-server/src/ReactFlightServer.js b/packages/react-server/src/ReactFlightServer.js index 1e84a89350c09..01c3db8f3fda8 100644 --- a/packages/react-server/src/ReactFlightServer.js +++ b/packages/react-server/src/ReactFlightServer.js @@ -91,23 +91,23 @@ export type ReactModel = | Iterable | ReactModelObject; -type ReactModelObject = {+[key: string]: ReactModel}; +type ReactModelObject = {|+[key: string]: ReactModel|}; const PENDING = 0; const COMPLETED = 1; const ABORTED = 3; const ERRORED = 4; -type Task = { +type Task = {| id: number, status: 0 | 1 | 3 | 4, model: ReactModel, ping: () => void, context: ContextSnapshot, thenableState: ThenableState | null, -}; +|}; -export type Request = { +export type Request = {| status: 0 | 1 | 2, fatalError: mixed, destination: null | Destination, @@ -127,7 +127,7 @@ export type Request = { identifierCount: number, onError: (error: mixed) => void, toJSON: (key: string, value: ReactModel) => ReactJSONValue, -}; +|}; const ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; @@ -272,6 +272,7 @@ function attemptResolveElement( ); } } + // $FlowFixMe issue discovered when updating Flow return [ REACT_ELEMENT_TYPE, type, @@ -324,7 +325,7 @@ function serializeByRefID(id: number): string { function serializeModuleReference( request: Request, - parent: {+[key: string | number]: ReactModel} | $ReadOnlyArray, + parent: {|+[key: string | number]: ReactModel|} | $ReadOnlyArray, key: string, moduleReference: ModuleReference, ): string { @@ -465,7 +466,7 @@ function describeValueForErrorMessage(value: ReactModel): string { function describeObjectForErrorMessage( objectOrArray: - | {+[key: string | number]: ReactModel} + | {+[key: string | number]: ReactModel, ...} | $ReadOnlyArray, expandedName?: string, ): string { @@ -495,7 +496,7 @@ function describeObjectForErrorMessage( return str; } else { let str = '{'; - const object: {+[key: string | number]: ReactModel} = objectOrArray; + const object: {+[key: string | number]: ReactModel, ...} = objectOrArray; const names = Object.keys(object); for (let i = 0; i < names.length; i++) { if (i > 0) { @@ -528,7 +529,7 @@ let isInsideContextValue = false; export function resolveModelToJSON( request: Request, - parent: {+[key: string | number]: ReactModel} | $ReadOnlyArray, + parent: {|+[key: string | number]: ReactModel|} | $ReadOnlyArray, key: string, value: ReactModel, ): ReactJSONValue { @@ -698,6 +699,7 @@ export function resolveModelToJSON( } } + // $FlowFixMe return value; } @@ -839,6 +841,7 @@ function emitModuleChunk( id: number, moduleMetaData: ModuleMetaData, ): void { + // $FlowFixMe ModuleMetaData is not a ReactModel const processedChunk = processModuleChunk(request, id, moduleMetaData); request.completedModuleChunks.push(processedChunk); } diff --git a/packages/react/src/ReactChildren.js b/packages/react/src/ReactChildren.js index 686d39a5716a9..73a23911f4d85 100644 --- a/packages/react/src/ReactChildren.js +++ b/packages/react/src/ReactChildren.js @@ -173,9 +173,9 @@ function mapIntoArray( } else { const iteratorFn = getIteratorFn(children); if (typeof iteratorFn === 'function') { - const iterableChildren: Iterable & { + const iterableChildren: Iterable & {| entries: any, - } = (children: any); + |} = (children: any); if (__DEV__) { // Warn about using Maps as children diff --git a/packages/react/src/ReactCurrentBatchConfig.js b/packages/react/src/ReactCurrentBatchConfig.js index 91737680b4aa8..5355a575bc04c 100644 --- a/packages/react/src/ReactCurrentBatchConfig.js +++ b/packages/react/src/ReactCurrentBatchConfig.js @@ -9,9 +9,9 @@ import type {BatchConfigTransition} from 'react-reconciler/src/ReactFiberTracingMarkerComponent.new'; -type BatchConfig = { +type BatchConfig = {| transition: BatchConfigTransition | null, -}; +|}; /** * Keeps track of the current batch's configuration such as how long an update * should suspend for if it needs to. diff --git a/packages/react/src/ReactLazy.js b/packages/react/src/ReactLazy.js index 4f786ed25f968..fd08087aa403d 100644 --- a/packages/react/src/ReactLazy.js +++ b/packages/react/src/ReactLazy.js @@ -16,25 +16,25 @@ const Pending = 0; const Resolved = 1; const Rejected = 2; -type UninitializedPayload = { +type UninitializedPayload = {| _status: -1, _result: () => Thenable<{default: T, ...}>, -}; +|}; -type PendingPayload = { +type PendingPayload = {| _status: 0, _result: Wakeable, -}; +|}; -type ResolvedPayload = { +type ResolvedPayload = {| _status: 1, - _result: {default: T}, -}; + _result: {default: T, ...}, +|}; -type RejectedPayload = { +type RejectedPayload = {| _status: 2, _result: mixed, -}; +|}; type Payload = | UninitializedPayload @@ -42,11 +42,11 @@ type Payload = | ResolvedPayload | RejectedPayload; -export type LazyComponent = { +export type LazyComponent = {| $$typeof: symbol | number, _payload: P, _init: (payload: P) => T, -}; +|}; function lazyInitializer(payload: Payload): T { if (payload._status === Uninitialized) { diff --git a/packages/scheduler/src/forks/SchedulerPostTask.js b/packages/scheduler/src/forks/SchedulerPostTask.js index c07f7f03819c3..94c5876d80c11 100644 --- a/packages/scheduler/src/forks/SchedulerPostTask.js +++ b/packages/scheduler/src/forks/SchedulerPostTask.js @@ -77,7 +77,7 @@ type SchedulerCallback = ( export function unstable_scheduleCallback( priorityLevel: PriorityLevel, callback: SchedulerCallback, - options?: {delay?: number}, + options?: {|delay?: number|}, ): CallbackNode { let postTaskPriority; switch (priorityLevel) { diff --git a/packages/shared/ReactTypes.js b/packages/shared/ReactTypes.js index 5209c795c239b..9ea076b15f9e7 100644 --- a/packages/shared/ReactTypes.js +++ b/packages/shared/ReactTypes.js @@ -80,7 +80,7 @@ export type ServerContextJSONValue = | number | null | $ReadOnlyArray - | {+[key: string]: ServerContextJSONValue}; + | {|+[key: string]: ServerContextJSONValue|}; export type ReactServerContext = ReactContext; @@ -209,9 +209,9 @@ export type OffscreenMode = | 'unstable-defer-without-hiding' | 'visible'; -export type StartTransitionOptions = { +export type StartTransitionOptions = {| name?: string, -}; +|}; // TODO: Add Context support export type Usable = Thenable | ReactContext; diff --git a/scripts/flow/config/flowconfig b/scripts/flow/config/flowconfig index a61f324d93e52..5bae0b389a968 100644 --- a/scripts/flow/config/flowconfig +++ b/scripts/flow/config/flowconfig @@ -37,6 +37,7 @@ [lints] untyped-type-import=error +implicit-inexact-object=error [options] server.max_workers=4 diff --git a/scripts/flow/environment.js b/scripts/flow/environment.js index f97bd32a43212..1c07cb0171a67 100644 --- a/scripts/flow/environment.js +++ b/scripts/flow/environment.js @@ -77,52 +77,52 @@ declare module 'fs/promises' { declare var access: (path: string, mode?: number) => Promise; declare var lstat: ( path: string, - options?: ?{bigint?: boolean}, + options?: ?{|bigint?: boolean|}, ) => Promise; declare var readdir: ( path: string, options?: | ?string - | { + | {| encoding?: ?string, withFileTypes?: ?boolean, - }, + |}, ) => Promise; declare var readFile: ( path: string, options?: | ?string - | { + | {| encoding?: ?string, - }, + |}, ) => Promise; declare var readlink: ( path: string, options?: | ?string - | { + | {| encoding?: ?string, - }, + |}, ) => Promise; declare var realpath: ( path: string, options?: | ?string - | { + | {| encoding?: ?string, - }, + |}, ) => Promise; declare var stat: ( path: string, - options?: ?{bigint?: boolean}, + options?: ?{|bigint?: boolean|}, ) => Promise; } declare module 'pg' { declare var Pool: ( options: mixed, - ) => { + ) => {| query: (query: string, values?: Array) => void, - }; + |}; } declare module 'util' { @@ -147,13 +147,13 @@ declare module 'util' { encodeInto( buffer: string, dest: Uint8Array, - ): {read: number, written: number}; + ): {|read: number, written: number|}; encoding: string; } } declare module 'pg/lib/utils' { - declare module.exports: { + declare module.exports: {| prepareValue(val: any): mixed, - }; + |}; } diff --git a/scripts/flow/react-native-host-hooks.js b/scripts/flow/react-native-host-hooks.js index 896964f063643..900c0d2fa667b 100644 --- a/scripts/flow/react-native-host-hooks.js +++ b/scripts/flow/react-native-host-hooks.js @@ -26,7 +26,7 @@ type RawEventEmitterEvent = $ReadOnly<{| // We expect, but do not/cannot require, that nativeEvent is an object // with the properties: key, elementType (string), type (string), tag (numeric), // and a stateNode of the native element/Fiber the event was emitted to. - nativeEvent: {[string]: mixed}, + nativeEvent: {[string]: mixed, ...}, |}>; declare module 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface' { diff --git a/scripts/flow/react-relay-hooks.js b/scripts/flow/react-relay-hooks.js index 9f452689976af..5344cacae2485 100644 --- a/scripts/flow/react-relay-hooks.js +++ b/scripts/flow/react-relay-hooks.js @@ -12,7 +12,7 @@ type JSONValue = | boolean | number | null - | {+[key: string]: JSONValue} + | {|+[key: string]: JSONValue|} | $ReadOnlyArray; declare module 'JSResourceReference' {