From fcea98ee21719a9c4020eaf9a75e242e06e5bbd5 Mon Sep 17 00:00:00 2001 From: Jan Kassens Date: Fri, 23 Sep 2022 10:28:00 -0400 Subject: [PATCH] Flow: add some missing types in react-reconciler (#25316) To enable the next Flow version, we need to annotate exported values. This adds a few automatically inferred types that didn't look huge or just `any`. --- packages/react-reconciler/src/ReactFiber.new.js | 12 ++++++------ packages/react-reconciler/src/ReactFiber.old.js | 12 ++++++------ packages/react-reconciler/src/ReactFiberAct.new.js | 2 +- packages/react-reconciler/src/ReactFiberAct.old.js | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiber.new.js b/packages/react-reconciler/src/ReactFiber.new.js index 484f954a6f4df..16297ef3bea4b 100644 --- a/packages/react-reconciler/src/ReactFiber.new.js +++ b/packages/react-reconciler/src/ReactFiber.new.js @@ -693,7 +693,7 @@ export function createFiberFromSuspense( mode: TypeOfMode, lanes: Lanes, key: null | string, -) { +): Fiber { const fiber = createFiber(SuspenseComponent, pendingProps, key, mode); fiber.elementType = REACT_SUSPENSE_TYPE; fiber.lanes = lanes; @@ -705,7 +705,7 @@ export function createFiberFromSuspenseList( mode: TypeOfMode, lanes: Lanes, key: null | string, -) { +): Fiber { const fiber = createFiber(SuspenseListComponent, pendingProps, key, mode); fiber.elementType = REACT_SUSPENSE_LIST_TYPE; fiber.lanes = lanes; @@ -717,7 +717,7 @@ export function createFiberFromOffscreen( mode: TypeOfMode, lanes: Lanes, key: null | string, -) { +): Fiber { const fiber = createFiber(OffscreenComponent, pendingProps, key, mode); fiber.elementType = REACT_OFFSCREEN_TYPE; fiber.lanes = lanes; @@ -736,7 +736,7 @@ export function createFiberFromLegacyHidden( mode: TypeOfMode, lanes: Lanes, key: null | string, -) { +): Fiber { const fiber = createFiber(LegacyHiddenComponent, pendingProps, key, mode); fiber.elementType = REACT_LEGACY_HIDDEN_TYPE; fiber.lanes = lanes; @@ -757,7 +757,7 @@ export function createFiberFromCache( mode: TypeOfMode, lanes: Lanes, key: null | string, -) { +): Fiber { const fiber = createFiber(CacheComponent, pendingProps, key, mode); fiber.elementType = REACT_CACHE_TYPE; fiber.lanes = lanes; @@ -769,7 +769,7 @@ export function createFiberFromTracingMarker( mode: TypeOfMode, lanes: Lanes, key: null | string, -) { +): Fiber { const fiber = createFiber(TracingMarkerComponent, pendingProps, key, mode); fiber.elementType = REACT_TRACING_MARKER_TYPE; fiber.lanes = lanes; diff --git a/packages/react-reconciler/src/ReactFiber.old.js b/packages/react-reconciler/src/ReactFiber.old.js index 60d52c2d0b827..5599141eec8a0 100644 --- a/packages/react-reconciler/src/ReactFiber.old.js +++ b/packages/react-reconciler/src/ReactFiber.old.js @@ -693,7 +693,7 @@ export function createFiberFromSuspense( mode: TypeOfMode, lanes: Lanes, key: null | string, -) { +): Fiber { const fiber = createFiber(SuspenseComponent, pendingProps, key, mode); fiber.elementType = REACT_SUSPENSE_TYPE; fiber.lanes = lanes; @@ -705,7 +705,7 @@ export function createFiberFromSuspenseList( mode: TypeOfMode, lanes: Lanes, key: null | string, -) { +): Fiber { const fiber = createFiber(SuspenseListComponent, pendingProps, key, mode); fiber.elementType = REACT_SUSPENSE_LIST_TYPE; fiber.lanes = lanes; @@ -717,7 +717,7 @@ export function createFiberFromOffscreen( mode: TypeOfMode, lanes: Lanes, key: null | string, -) { +): Fiber { const fiber = createFiber(OffscreenComponent, pendingProps, key, mode); fiber.elementType = REACT_OFFSCREEN_TYPE; fiber.lanes = lanes; @@ -736,7 +736,7 @@ export function createFiberFromLegacyHidden( mode: TypeOfMode, lanes: Lanes, key: null | string, -) { +): Fiber { const fiber = createFiber(LegacyHiddenComponent, pendingProps, key, mode); fiber.elementType = REACT_LEGACY_HIDDEN_TYPE; fiber.lanes = lanes; @@ -757,7 +757,7 @@ export function createFiberFromCache( mode: TypeOfMode, lanes: Lanes, key: null | string, -) { +): Fiber { const fiber = createFiber(CacheComponent, pendingProps, key, mode); fiber.elementType = REACT_CACHE_TYPE; fiber.lanes = lanes; @@ -769,7 +769,7 @@ export function createFiberFromTracingMarker( mode: TypeOfMode, lanes: Lanes, key: null | string, -) { +): Fiber { const fiber = createFiber(TracingMarkerComponent, pendingProps, key, mode); fiber.elementType = REACT_TRACING_MARKER_TYPE; fiber.lanes = lanes; diff --git a/packages/react-reconciler/src/ReactFiberAct.new.js b/packages/react-reconciler/src/ReactFiberAct.new.js index 53a4922ad5417..fbb12f4bd178b 100644 --- a/packages/react-reconciler/src/ReactFiberAct.new.js +++ b/packages/react-reconciler/src/ReactFiberAct.new.js @@ -37,7 +37,7 @@ export function isLegacyActEnvironment(fiber: Fiber): boolean { return false; } -export function isConcurrentActEnvironment() { +export function isConcurrentActEnvironment(): void | boolean { if (__DEV__) { const isReactActEnvironmentGlobal = // $FlowFixMe – Flow doesn't know about IS_REACT_ACT_ENVIRONMENT global diff --git a/packages/react-reconciler/src/ReactFiberAct.old.js b/packages/react-reconciler/src/ReactFiberAct.old.js index 32d3a0f270719..90f771b594059 100644 --- a/packages/react-reconciler/src/ReactFiberAct.old.js +++ b/packages/react-reconciler/src/ReactFiberAct.old.js @@ -37,7 +37,7 @@ export function isLegacyActEnvironment(fiber: Fiber): boolean { return false; } -export function isConcurrentActEnvironment() { +export function isConcurrentActEnvironment(): void | boolean { if (__DEV__) { const isReactActEnvironmentGlobal = // $FlowFixMe – Flow doesn't know about IS_REACT_ACT_ENVIRONMENT global