diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js index 2cb6e7fbdf386..a09da97f90d72 100644 --- a/packages/react-debug-tools/src/ReactDebugHooks.js +++ b/packages/react-debug-tools/src/ReactDebugHooks.js @@ -783,7 +783,7 @@ export function inspectHooksOfFiber( fiber: Fiber, currentDispatcher: ?CurrentDispatcherRef, includeHooksSource?: boolean = false, -) { +): HooksTree { // DevTools will pass the current renderer's injected dispatcher. // Other apps might compile debug hooks as part of their app though. if (currentDispatcher == null) { diff --git a/packages/react-dom/src/client/ReactDOMHostConfig.js b/packages/react-dom/src/client/ReactDOMHostConfig.js index c9c6e11fdfe00..64195ac7f5957 100644 --- a/packages/react-dom/src/client/ReactDOMHostConfig.js +++ b/packages/react-dom/src/client/ReactDOMHostConfig.js @@ -680,7 +680,7 @@ export function clearContainer(container: Container): void { export const supportsHydration = true; -export function isHydratableResource(type: string, props: Props) { +export function isHydratableResource(type: string, props: Props): boolean { return ( type === 'link' && typeof (props: any).precedence === 'string' && @@ -726,11 +726,13 @@ export function canHydrateSuspenseInstance( return ((instance: any): SuspenseInstance); } -export function isSuspenseInstancePending(instance: SuspenseInstance) { +export function isSuspenseInstancePending(instance: SuspenseInstance): boolean { return instance.data === SUSPENSE_PENDING_START_DATA; } -export function isSuspenseInstanceFallback(instance: SuspenseInstance) { +export function isSuspenseInstanceFallback( + instance: SuspenseInstance, +): boolean { return instance.data === SUSPENSE_FALLBACK_START_DATA; } diff --git a/packages/react-dom/src/client/inputValueTracking.js b/packages/react-dom/src/client/inputValueTracking.js index 6bec33f9b0432..2c279331e8adc 100644 --- a/packages/react-dom/src/client/inputValueTracking.js +++ b/packages/react-dom/src/client/inputValueTracking.js @@ -123,7 +123,7 @@ export function track(node: ElementWithValueTracker) { node._valueTracker = trackValueOnNode(node); } -export function updateValueIfChanged(node: ElementWithValueTracker) { +export function updateValueIfChanged(node: ElementWithValueTracker): boolean { if (!node) { return false; } diff --git a/packages/react-dom/src/events/checkPassiveEvents.js b/packages/react-dom/src/events/checkPassiveEvents.js index 12680a885ebde..396060867414b 100644 --- a/packages/react-dom/src/events/checkPassiveEvents.js +++ b/packages/react-dom/src/events/checkPassiveEvents.js @@ -9,7 +9,7 @@ import {canUseDOM} from 'shared/ExecutionEnvironment'; -export let passiveBrowserEventsSupported = false; +export let passiveBrowserEventsSupported: boolean = false; // Check if browser support events with passive listeners // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support diff --git a/packages/react-dom/src/shared/DOMProperty.js b/packages/react-dom/src/shared/DOMProperty.js index 09f1dd2b66a31..0ae244d8c98a3 100644 --- a/packages/react-dom/src/shared/DOMProperty.js +++ b/packages/react-dom/src/shared/DOMProperty.js @@ -63,10 +63,10 @@ export type PropertyInfo = { export const ATTRIBUTE_NAME_START_CHAR = ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD'; /* eslint-enable max-len */ -export const ATTRIBUTE_NAME_CHAR = +export const ATTRIBUTE_NAME_CHAR: string = ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040'; -export const VALID_ATTRIBUTE_NAME_REGEX = new RegExp( +export const VALID_ATTRIBUTE_NAME_REGEX: RegExp = new RegExp( '^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$', ); diff --git a/packages/react-dom/src/shared/isCustomComponent.js b/packages/react-dom/src/shared/isCustomComponent.js index aa6b2903c0e71..e94bc239d9c48 100644 --- a/packages/react-dom/src/shared/isCustomComponent.js +++ b/packages/react-dom/src/shared/isCustomComponent.js @@ -7,7 +7,7 @@ * @flow */ -function isCustomComponent(tagName: string, props: Object) { +function isCustomComponent(tagName: string, props: Object): boolean { if (tagName.indexOf('-') === -1) { return typeof props.is === 'string'; } diff --git a/packages/react-is/src/ReactIs.js b/packages/react-is/src/ReactIs.js index 8c5d26a08c2ae..26bf7e3c6b36d 100644 --- a/packages/react-is/src/ReactIs.js +++ b/packages/react-is/src/ReactIs.js @@ -82,7 +82,7 @@ let hasWarnedAboutDeprecatedIsAsyncMode = false; let hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated -export function isAsyncMode(object: any) { +export function isAsyncMode(object: any): boolean { if (__DEV__) { if (!hasWarnedAboutDeprecatedIsAsyncMode) { hasWarnedAboutDeprecatedIsAsyncMode = true; @@ -95,7 +95,7 @@ export function isAsyncMode(object: any) { } return false; } -export function isConcurrentMode(object: any) { +export function isConcurrentMode(object: any): boolean { if (__DEV__) { if (!hasWarnedAboutDeprecatedIsConcurrentMode) { hasWarnedAboutDeprecatedIsConcurrentMode = true; @@ -108,43 +108,43 @@ export function isConcurrentMode(object: any) { } return false; } -export function isContextConsumer(object: any) { +export function isContextConsumer(object: any): boolean { return typeOf(object) === REACT_CONTEXT_TYPE; } -export function isContextProvider(object: any) { +export function isContextProvider(object: any): boolean { return typeOf(object) === REACT_PROVIDER_TYPE; } -export function isElement(object: any) { +export function isElement(object: any): boolean { return ( typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE ); } -export function isForwardRef(object: any) { +export function isForwardRef(object: any): boolean { return typeOf(object) === REACT_FORWARD_REF_TYPE; } -export function isFragment(object: any) { +export function isFragment(object: any): boolean { return typeOf(object) === REACT_FRAGMENT_TYPE; } -export function isLazy(object: any) { +export function isLazy(object: any): boolean { return typeOf(object) === REACT_LAZY_TYPE; } -export function isMemo(object: any) { +export function isMemo(object: any): boolean { return typeOf(object) === REACT_MEMO_TYPE; } -export function isPortal(object: any) { +export function isPortal(object: any): boolean { return typeOf(object) === REACT_PORTAL_TYPE; } -export function isProfiler(object: any) { +export function isProfiler(object: any): boolean { return typeOf(object) === REACT_PROFILER_TYPE; } -export function isStrictMode(object: any) { +export function isStrictMode(object: any): boolean { return typeOf(object) === REACT_STRICT_MODE_TYPE; } -export function isSuspense(object: any) { +export function isSuspense(object: any): boolean { return typeOf(object) === REACT_SUSPENSE_TYPE; } -export function isSuspenseList(object: any) { +export function isSuspenseList(object: any): boolean { return typeOf(object) === REACT_SUSPENSE_LIST_TYPE; } diff --git a/packages/react-reconciler/src/ReactCurrentFiber.js b/packages/react-reconciler/src/ReactCurrentFiber.js index 08853b384bc65..5c9fa7a052362 100644 --- a/packages/react-reconciler/src/ReactCurrentFiber.js +++ b/packages/react-reconciler/src/ReactCurrentFiber.js @@ -73,7 +73,7 @@ export function setIsRendering(rendering: boolean) { } } -export function getIsRendering() { +export function getIsRendering(): void | boolean { if (__DEV__) { return isRendering; } diff --git a/packages/react-reconciler/src/ReactEventPriorities.js b/packages/react-reconciler/src/ReactEventPriorities.js index 46223aa70df55..faf30c3338ad9 100644 --- a/packages/react-reconciler/src/ReactEventPriorities.js +++ b/packages/react-reconciler/src/ReactEventPriorities.js @@ -58,7 +58,7 @@ export function getCurrentUpdatePriority(): EventPriority { : (getCurrentUpdatePriority_old(): any); } -export function setCurrentUpdatePriority(priority: EventPriority) { +export function setCurrentUpdatePriority(priority: EventPriority): void { return enableNewReconciler ? setCurrentUpdatePriority_new((priority: any)) : setCurrentUpdatePriority_old((priority: any)); diff --git a/packages/react-reconciler/src/ReactFiber.new.js b/packages/react-reconciler/src/ReactFiber.new.js index d6a6c8f7adc19..484f954a6f4df 100644 --- a/packages/react-reconciler/src/ReactFiber.new.js +++ b/packages/react-reconciler/src/ReactFiber.new.js @@ -225,7 +225,7 @@ function shouldConstruct(Component: Function) { return !!(prototype && prototype.isReactComponent); } -export function isSimpleFunctionComponent(type: any) { +export function isSimpleFunctionComponent(type: any): boolean { return ( typeof type === 'function' && !shouldConstruct(type) && @@ -355,7 +355,10 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber { } // Used to reuse a Fiber for a second pass. -export function resetWorkInProgress(workInProgress: Fiber, renderLanes: Lanes) { +export function resetWorkInProgress( + workInProgress: Fiber, + renderLanes: Lanes, +): Fiber { // This resets the Fiber to what createFiber or createWorkInProgress would // have set the values to before during the first pass. Ideally this wouldn't // be necessary but unfortunately many code paths reads from the workInProgress diff --git a/packages/react-reconciler/src/ReactFiber.old.js b/packages/react-reconciler/src/ReactFiber.old.js index d8f1ef424bd13..60d52c2d0b827 100644 --- a/packages/react-reconciler/src/ReactFiber.old.js +++ b/packages/react-reconciler/src/ReactFiber.old.js @@ -225,7 +225,7 @@ function shouldConstruct(Component: Function) { return !!(prototype && prototype.isReactComponent); } -export function isSimpleFunctionComponent(type: any) { +export function isSimpleFunctionComponent(type: any): boolean { return ( typeof type === 'function' && !shouldConstruct(type) && @@ -355,7 +355,10 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber { } // Used to reuse a Fiber for a second pass. -export function resetWorkInProgress(workInProgress: Fiber, renderLanes: Lanes) { +export function resetWorkInProgress( + workInProgress: Fiber, + renderLanes: Lanes, +): Fiber { // This resets the Fiber to what createFiber or createWorkInProgress would // have set the values to before during the first pass. Ideally this wouldn't // be necessary but unfortunately many code paths reads from the workInProgress diff --git a/packages/react-reconciler/src/ReactFiberAct.new.js b/packages/react-reconciler/src/ReactFiberAct.new.js index bad7fd3dc52f7..53a4922ad5417 100644 --- a/packages/react-reconciler/src/ReactFiberAct.new.js +++ b/packages/react-reconciler/src/ReactFiberAct.new.js @@ -15,7 +15,7 @@ import {warnsIfNotActing} from './ReactFiberHostConfig'; const {ReactCurrentActQueue} = ReactSharedInternals; -export function isLegacyActEnvironment(fiber: Fiber) { +export function isLegacyActEnvironment(fiber: Fiber): boolean { if (__DEV__) { // Legacy mode. We preserve the behavior of React 17's act. It assumes an // act environment whenever `jest` is defined, but you can still turn off diff --git a/packages/react-reconciler/src/ReactFiberAct.old.js b/packages/react-reconciler/src/ReactFiberAct.old.js index 6358ab66a3485..32d3a0f270719 100644 --- a/packages/react-reconciler/src/ReactFiberAct.old.js +++ b/packages/react-reconciler/src/ReactFiberAct.old.js @@ -15,7 +15,7 @@ import {warnsIfNotActing} from './ReactFiberHostConfig'; const {ReactCurrentActQueue} = ReactSharedInternals; -export function isLegacyActEnvironment(fiber: Fiber) { +export function isLegacyActEnvironment(fiber: Fiber): boolean { if (__DEV__) { // Legacy mode. We preserve the behavior of React 17's act. It assumes an // act environment whenever `jest` is defined, but you can still turn off diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.new.js b/packages/react-reconciler/src/ReactFiberBeginWork.new.js index fa417e08114c9..913a054be2dd2 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.new.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.new.js @@ -281,7 +281,7 @@ let didWarnAboutModulePatternComponent; let didWarnAboutContextTypeOnFunctionComponent; let didWarnAboutGetDerivedStateOnFunctionComponent; let didWarnAboutFunctionRefs; -export let didWarnAboutReassigningProps; +export let didWarnAboutReassigningProps: boolean; let didWarnAboutRevealOrder; let didWarnAboutTailOptions; let didWarnAboutDefaultPropsOnFunctionComponent; @@ -3479,7 +3479,7 @@ export function markWorkInProgressReceivedUpdate() { didReceiveUpdate = true; } -export function checkIfWorkInProgressReceivedUpdate() { +export function checkIfWorkInProgressReceivedUpdate(): boolean { return didReceiveUpdate; } diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.old.js b/packages/react-reconciler/src/ReactFiberBeginWork.old.js index 449f306e7ef89..382e9075716af 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.old.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.old.js @@ -281,7 +281,7 @@ let didWarnAboutModulePatternComponent; let didWarnAboutContextTypeOnFunctionComponent; let didWarnAboutGetDerivedStateOnFunctionComponent; let didWarnAboutFunctionRefs; -export let didWarnAboutReassigningProps; +export let didWarnAboutReassigningProps: boolean; let didWarnAboutRevealOrder; let didWarnAboutTailOptions; let didWarnAboutDefaultPropsOnFunctionComponent; @@ -3479,7 +3479,7 @@ export function markWorkInProgressReceivedUpdate() { didReceiveUpdate = true; } -export function checkIfWorkInProgressReceivedUpdate() { +export function checkIfWorkInProgressReceivedUpdate(): boolean { return didReceiveUpdate; } diff --git a/packages/react-reconciler/src/ReactFiberClassUpdateQueue.new.js b/packages/react-reconciler/src/ReactFiberClassUpdateQueue.new.js index 5bdc8fc6a82a0..5bf0a7a376cec 100644 --- a/packages/react-reconciler/src/ReactFiberClassUpdateQueue.new.js +++ b/packages/react-reconciler/src/ReactFiberClassUpdateQueue.new.js @@ -164,7 +164,7 @@ let hasForceUpdate = false; let didWarnUpdateInsideUpdate; let currentlyProcessingQueue; -export let resetCurrentlyProcessingQueue; +export let resetCurrentlyProcessingQueue: () => void; if (__DEV__) { didWarnUpdateInsideUpdate = false; currentlyProcessingQueue = null; diff --git a/packages/react-reconciler/src/ReactFiberClassUpdateQueue.old.js b/packages/react-reconciler/src/ReactFiberClassUpdateQueue.old.js index bdff2ea93e704..c9918ae104c01 100644 --- a/packages/react-reconciler/src/ReactFiberClassUpdateQueue.old.js +++ b/packages/react-reconciler/src/ReactFiberClassUpdateQueue.old.js @@ -164,7 +164,7 @@ let hasForceUpdate = false; let didWarnUpdateInsideUpdate; let currentlyProcessingQueue; -export let resetCurrentlyProcessingQueue; +export let resetCurrentlyProcessingQueue: () => void; if (__DEV__) { didWarnUpdateInsideUpdate = false; currentlyProcessingQueue = null; diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.new.js b/packages/react-reconciler/src/ReactFiberCommitWork.new.js index c70e4ae3470e7..1710bcfc861e7 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.new.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.new.js @@ -320,7 +320,7 @@ let shouldFireAfterActiveInstanceBlur: boolean = false; export function commitBeforeMutationEffects( root: FiberRoot, firstChild: Fiber, -) { +): boolean { focusedInstanceHandle = prepareForCommit(root.containerInfo); nextEffect = firstChild; diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.old.js b/packages/react-reconciler/src/ReactFiberCommitWork.old.js index 4b5076a61c51f..a7a8929d2b68c 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.old.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.old.js @@ -320,7 +320,7 @@ let shouldFireAfterActiveInstanceBlur: boolean = false; export function commitBeforeMutationEffects( root: FiberRoot, firstChild: Fiber, -) { +): boolean { focusedInstanceHandle = prepareForCommit(root.containerInfo); nextEffect = firstChild; diff --git a/packages/react-reconciler/src/ReactFiberHiddenContext.new.js b/packages/react-reconciler/src/ReactFiberHiddenContext.new.js index 3ce3490a3990e..d44178a3efc8c 100644 --- a/packages/react-reconciler/src/ReactFiberHiddenContext.new.js +++ b/packages/react-reconciler/src/ReactFiberHiddenContext.new.js @@ -66,6 +66,6 @@ export function popHiddenContext(fiber: Fiber): void { pop(prevRenderLanesStackCursor, fiber); } -export function isCurrentTreeHidden() { +export function isCurrentTreeHidden(): boolean { return currentTreeHiddenStackCursor.current !== null; } diff --git a/packages/react-reconciler/src/ReactFiberHiddenContext.old.js b/packages/react-reconciler/src/ReactFiberHiddenContext.old.js index 565dc4ae20e9f..1886dfef8bb53 100644 --- a/packages/react-reconciler/src/ReactFiberHiddenContext.old.js +++ b/packages/react-reconciler/src/ReactFiberHiddenContext.old.js @@ -66,6 +66,6 @@ export function popHiddenContext(fiber: Fiber): void { pop(prevRenderLanesStackCursor, fiber); } -export function isCurrentTreeHidden() { +export function isCurrentTreeHidden(): boolean { return currentTreeHiddenStackCursor.current !== null; } diff --git a/packages/react-reconciler/src/ReactFiberHooks.new.js b/packages/react-reconciler/src/ReactFiberHooks.new.js index 602f855c76d85..b602c3691471e 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.new.js +++ b/packages/react-reconciler/src/ReactFiberHooks.new.js @@ -571,7 +571,7 @@ export function renderWithHooks( return children; } -export function checkDidRenderIdHook() { +export function checkDidRenderIdHook(): boolean { // This should be called immediately after every renderWithHooks call. // Conceptually, it's part of the return value of renderWithHooks; it's only a // separate function to avoid using an array tuple. diff --git a/packages/react-reconciler/src/ReactFiberHooks.old.js b/packages/react-reconciler/src/ReactFiberHooks.old.js index f2b024bee943d..9f0cb1914581f 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.old.js +++ b/packages/react-reconciler/src/ReactFiberHooks.old.js @@ -571,7 +571,7 @@ export function renderWithHooks( return children; } -export function checkDidRenderIdHook() { +export function checkDidRenderIdHook(): boolean { // This should be called immediately after every renderWithHooks call. // Conceptually, it's part of the return value of renderWithHooks; it's only a // separate function to avoid using an array tuple. diff --git a/packages/react-reconciler/src/ReactFiberHotReloading.js b/packages/react-reconciler/src/ReactFiberHotReloading.js index 0d3fdca45ceff..385ee8bfcd8e2 100644 --- a/packages/react-reconciler/src/ReactFiberHotReloading.js +++ b/packages/react-reconciler/src/ReactFiberHotReloading.js @@ -7,6 +7,8 @@ * @flow */ +import type {Fiber} from './ReactInternalTypes'; +import type {ReactElement} from '../../shared/ReactElementType'; import type {Instance} from './ReactFiberHostConfig'; import type {FiberRoot} from './ReactInternalTypes'; import type {ReactNodeList} from 'shared/ReactTypes'; @@ -58,9 +60,9 @@ export type FindHostInstancesForRefresh = ( families: Array, ) => Set; -export const setRefreshHandler = enableNewReconciler - ? setRefreshHandler_new - : setRefreshHandler_old; +export const setRefreshHandler: ( + handler: RefreshHandler | null, +) => void = enableNewReconciler ? setRefreshHandler_new : setRefreshHandler_old; export const resolveFunctionForHotReloading = enableNewReconciler ? resolveFunctionForHotReloading_new : resolveFunctionForHotReloading_old; @@ -70,18 +72,23 @@ export const resolveClassForHotReloading = enableNewReconciler export const resolveForwardRefForHotReloading = enableNewReconciler ? resolveForwardRefForHotReloading_new : resolveForwardRefForHotReloading_old; -export const isCompatibleFamilyForHotReloading = enableNewReconciler +export const isCompatibleFamilyForHotReloading: ( + fiber: Fiber, + element: ReactElement, +) => boolean = enableNewReconciler ? isCompatibleFamilyForHotReloading_new : isCompatibleFamilyForHotReloading_old; -export const markFailedErrorBoundaryForHotReloading = enableNewReconciler +export const markFailedErrorBoundaryForHotReloading: ( + fiber: Fiber, +) => void = enableNewReconciler ? markFailedErrorBoundaryForHotReloading_new : markFailedErrorBoundaryForHotReloading_old; -export const scheduleRefresh = enableNewReconciler +export const scheduleRefresh: ScheduleRefresh = enableNewReconciler ? scheduleRefresh_new : scheduleRefresh_old; -export const scheduleRoot = enableNewReconciler +export const scheduleRoot: ScheduleRoot = enableNewReconciler ? scheduleRoot_new : scheduleRoot_old; -export const findHostInstancesForRefresh = enableNewReconciler +export const findHostInstancesForRefresh: FindHostInstancesForRefresh = enableNewReconciler ? findHostInstancesForRefresh_new : findHostInstancesForRefresh_old; diff --git a/packages/react-reconciler/src/ReactFiberHydrationContext.new.js b/packages/react-reconciler/src/ReactFiberHydrationContext.new.js index 23010daad4970..66c28274ae0cf 100644 --- a/packages/react-reconciler/src/ReactFiberHydrationContext.new.js +++ b/packages/react-reconciler/src/ReactFiberHydrationContext.new.js @@ -109,7 +109,7 @@ export function markDidThrowWhileHydratingDEV() { } } -export function didSuspendOrErrorWhileHydratingDEV() { +export function didSuspendOrErrorWhileHydratingDEV(): boolean { if (__DEV__) { return didSuspendOrErrorDEV; } @@ -685,7 +685,7 @@ function popHydrationState(fiber: Fiber): boolean { return true; } -function hasUnhydratedTailNodes() { +function hasUnhydratedTailNodes(): boolean { return isHydrating && nextHydratableInstance !== null; } diff --git a/packages/react-reconciler/src/ReactFiberHydrationContext.old.js b/packages/react-reconciler/src/ReactFiberHydrationContext.old.js index 28371e823e5c8..10e59b1d2bf0a 100644 --- a/packages/react-reconciler/src/ReactFiberHydrationContext.old.js +++ b/packages/react-reconciler/src/ReactFiberHydrationContext.old.js @@ -109,7 +109,7 @@ export function markDidThrowWhileHydratingDEV() { } } -export function didSuspendOrErrorWhileHydratingDEV() { +export function didSuspendOrErrorWhileHydratingDEV(): boolean { if (__DEV__) { return didSuspendOrErrorDEV; } @@ -685,7 +685,7 @@ function popHydrationState(fiber: Fiber): boolean { return true; } -function hasUnhydratedTailNodes() { +function hasUnhydratedTailNodes(): boolean { return isHydrating && nextHydratableInstance !== null; } diff --git a/packages/react-reconciler/src/ReactFiberLane.new.js b/packages/react-reconciler/src/ReactFiberLane.new.js index 2dcbe70ee7960..36af3b95becea 100644 --- a/packages/react-reconciler/src/ReactFiberLane.new.js +++ b/packages/react-reconciler/src/ReactFiberLane.new.js @@ -435,7 +435,7 @@ export function markStarvedLanesAsExpired( // This returns the highest priority pending lanes regardless of whether they // are suspended. -export function getHighestPriorityPendingLanes(root: FiberRoot) { +export function getHighestPriorityPendingLanes(root: FiberRoot): Lanes { return getHighestPriorityLanes(root.pendingLanes); } @@ -458,25 +458,25 @@ export function getLanesToRetrySynchronouslyOnError( return NoLanes; } -export function includesSyncLane(lanes: Lanes) { +export function includesSyncLane(lanes: Lanes): boolean { return (lanes & SyncLane) !== NoLanes; } -export function includesNonIdleWork(lanes: Lanes) { +export function includesNonIdleWork(lanes: Lanes): boolean { return (lanes & NonIdleLanes) !== NoLanes; } -export function includesOnlyRetries(lanes: Lanes) { +export function includesOnlyRetries(lanes: Lanes): boolean { return (lanes & RetryLanes) === lanes; } -export function includesOnlyNonUrgentLanes(lanes: Lanes) { +export function includesOnlyNonUrgentLanes(lanes: Lanes): boolean { const UrgentLanes = SyncLane | InputContinuousLane | DefaultLane; return (lanes & UrgentLanes) === NoLanes; } -export function includesOnlyTransitions(lanes: Lanes) { +export function includesOnlyTransitions(lanes: Lanes): boolean { return (lanes & TransitionLanes) === lanes; } -export function includesBlockingLane(root: FiberRoot, lanes: Lanes) { +export function includesBlockingLane(root: FiberRoot, lanes: Lanes): boolean { if ( allowConcurrentByDefault && (root.current.mode & ConcurrentUpdatesByDefaultMode) !== NoMode @@ -492,13 +492,13 @@ export function includesBlockingLane(root: FiberRoot, lanes: Lanes) { return (lanes & SyncDefaultLanes) !== NoLanes; } -export function includesExpiredLane(root: FiberRoot, lanes: Lanes) { +export function includesExpiredLane(root: FiberRoot, lanes: Lanes): boolean { // This is a separate check from includesBlockingLane because a lane can // expire after a render has already started. return (lanes & root.expiredLanes) !== NoLanes; } -export function isTransitionLane(lane: Lane) { +export function isTransitionLane(lane: Lane): boolean { return (lane & TransitionLanes) !== NoLanes; } @@ -543,11 +543,11 @@ function laneToIndex(lane: Lane) { return pickArbitraryLaneIndex(lane); } -export function includesSomeLane(a: Lanes | Lane, b: Lanes | Lane) { +export function includesSomeLane(a: Lanes | Lane, b: Lanes | Lane): boolean { return (a & b) !== NoLanes; } -export function isSubsetOfLanes(set: Lanes, subset: Lanes | Lane) { +export function isSubsetOfLanes(set: Lanes, subset: Lanes | Lane): boolean { return (set & subset) === subset; } @@ -569,7 +569,7 @@ export function laneToLanes(lane: Lane): Lanes { return lane; } -export function higherPriorityLane(a: Lane, b: Lane) { +export function higherPriorityLane(a: Lane, b: Lane): Lane { // This works because the bit ranges decrease in priority as you go left. return a !== NoLane && a < b ? a : b; } diff --git a/packages/react-reconciler/src/ReactFiberLane.old.js b/packages/react-reconciler/src/ReactFiberLane.old.js index 6042a1a31c429..38fe4700dff47 100644 --- a/packages/react-reconciler/src/ReactFiberLane.old.js +++ b/packages/react-reconciler/src/ReactFiberLane.old.js @@ -435,7 +435,7 @@ export function markStarvedLanesAsExpired( // This returns the highest priority pending lanes regardless of whether they // are suspended. -export function getHighestPriorityPendingLanes(root: FiberRoot) { +export function getHighestPriorityPendingLanes(root: FiberRoot): Lanes { return getHighestPriorityLanes(root.pendingLanes); } @@ -458,25 +458,25 @@ export function getLanesToRetrySynchronouslyOnError( return NoLanes; } -export function includesSyncLane(lanes: Lanes) { +export function includesSyncLane(lanes: Lanes): boolean { return (lanes & SyncLane) !== NoLanes; } -export function includesNonIdleWork(lanes: Lanes) { +export function includesNonIdleWork(lanes: Lanes): boolean { return (lanes & NonIdleLanes) !== NoLanes; } -export function includesOnlyRetries(lanes: Lanes) { +export function includesOnlyRetries(lanes: Lanes): boolean { return (lanes & RetryLanes) === lanes; } -export function includesOnlyNonUrgentLanes(lanes: Lanes) { +export function includesOnlyNonUrgentLanes(lanes: Lanes): boolean { const UrgentLanes = SyncLane | InputContinuousLane | DefaultLane; return (lanes & UrgentLanes) === NoLanes; } -export function includesOnlyTransitions(lanes: Lanes) { +export function includesOnlyTransitions(lanes: Lanes): boolean { return (lanes & TransitionLanes) === lanes; } -export function includesBlockingLane(root: FiberRoot, lanes: Lanes) { +export function includesBlockingLane(root: FiberRoot, lanes: Lanes): boolean { if ( allowConcurrentByDefault && (root.current.mode & ConcurrentUpdatesByDefaultMode) !== NoMode @@ -492,13 +492,13 @@ export function includesBlockingLane(root: FiberRoot, lanes: Lanes) { return (lanes & SyncDefaultLanes) !== NoLanes; } -export function includesExpiredLane(root: FiberRoot, lanes: Lanes) { +export function includesExpiredLane(root: FiberRoot, lanes: Lanes): boolean { // This is a separate check from includesBlockingLane because a lane can // expire after a render has already started. return (lanes & root.expiredLanes) !== NoLanes; } -export function isTransitionLane(lane: Lane) { +export function isTransitionLane(lane: Lane): boolean { return (lane & TransitionLanes) !== NoLanes; } @@ -543,11 +543,11 @@ function laneToIndex(lane: Lane) { return pickArbitraryLaneIndex(lane); } -export function includesSomeLane(a: Lanes | Lane, b: Lanes | Lane) { +export function includesSomeLane(a: Lanes | Lane, b: Lanes | Lane): boolean { return (a & b) !== NoLanes; } -export function isSubsetOfLanes(set: Lanes, subset: Lanes | Lane) { +export function isSubsetOfLanes(set: Lanes, subset: Lanes | Lane): boolean { return (set & subset) === subset; } @@ -569,7 +569,7 @@ export function laneToLanes(lane: Lane): Lanes { return lane; } -export function higherPriorityLane(a: Lane, b: Lane) { +export function higherPriorityLane(a: Lane, b: Lane): Lane { // This works because the bit ranges decrease in priority as you go left. return a !== NoLane && a < b ? a : b; } diff --git a/packages/react-reconciler/src/ReactFiberNewContext.new.js b/packages/react-reconciler/src/ReactFiberNewContext.new.js index eae7b232c5eb5..a311b101d3a4e 100644 --- a/packages/react-reconciler/src/ReactFiberNewContext.new.js +++ b/packages/react-reconciler/src/ReactFiberNewContext.new.js @@ -598,7 +598,9 @@ function propagateParentContextChanges( workInProgress.flags |= DidPropagateContext; } -export function checkIfContextChanged(currentDependencies: Dependencies) { +export function checkIfContextChanged( + currentDependencies: Dependencies, +): boolean { if (!enableLazyContextPropagation) { return false; } diff --git a/packages/react-reconciler/src/ReactFiberNewContext.old.js b/packages/react-reconciler/src/ReactFiberNewContext.old.js index cbc2d0069b356..0833d58806e9b 100644 --- a/packages/react-reconciler/src/ReactFiberNewContext.old.js +++ b/packages/react-reconciler/src/ReactFiberNewContext.old.js @@ -598,7 +598,9 @@ function propagateParentContextChanges( workInProgress.flags |= DidPropagateContext; } -export function checkIfContextChanged(currentDependencies: Dependencies) { +export function checkIfContextChanged( + currentDependencies: Dependencies, +): boolean { if (!enableLazyContextPropagation) { return false; } diff --git a/packages/react-reconciler/src/ReactFiberShellHydration.js b/packages/react-reconciler/src/ReactFiberShellHydration.js index caadb978f69d0..296c763e01b05 100644 --- a/packages/react-reconciler/src/ReactFiberShellHydration.js +++ b/packages/react-reconciler/src/ReactFiberShellHydration.js @@ -13,7 +13,7 @@ import type {RootState} from './ReactFiberRoot.new'; // This is imported by the event replaying implementation in React DOM. It's // in a separate file to break a circular dependency between the renderer and // the reconciler. -export function isRootDehydrated(root: FiberRoot) { +export function isRootDehydrated(root: FiberRoot): boolean { const currentState: RootState = root.current.memoizedState; return currentState.isDehydrated; } diff --git a/packages/react-reconciler/src/ReactFiberSyncTaskQueue.new.js b/packages/react-reconciler/src/ReactFiberSyncTaskQueue.new.js index 0f72c3fbc863a..73c04034b7e9d 100644 --- a/packages/react-reconciler/src/ReactFiberSyncTaskQueue.new.js +++ b/packages/react-reconciler/src/ReactFiberSyncTaskQueue.new.js @@ -48,7 +48,7 @@ export function flushSyncCallbacksOnlyInLegacyMode() { } } -export function flushSyncCallbacks() { +export function flushSyncCallbacks(): null { if (!isFlushingSyncQueue && syncQueue !== null) { // Prevent re-entrance. isFlushingSyncQueue = true; diff --git a/packages/react-reconciler/src/ReactFiberSyncTaskQueue.old.js b/packages/react-reconciler/src/ReactFiberSyncTaskQueue.old.js index 56422a38b137a..12d8371b72251 100644 --- a/packages/react-reconciler/src/ReactFiberSyncTaskQueue.old.js +++ b/packages/react-reconciler/src/ReactFiberSyncTaskQueue.old.js @@ -48,7 +48,7 @@ export function flushSyncCallbacksOnlyInLegacyMode() { } } -export function flushSyncCallbacks() { +export function flushSyncCallbacks(): null { if (!isFlushingSyncQueue && syncQueue !== null) { // Prevent re-entrance. isFlushingSyncQueue = true; diff --git a/packages/react-reconciler/src/ReactFiberWakeable.new.js b/packages/react-reconciler/src/ReactFiberWakeable.new.js index e494aa34fc1f2..11f470cfab888 100644 --- a/packages/react-reconciler/src/ReactFiberWakeable.new.js +++ b/packages/react-reconciler/src/ReactFiberWakeable.new.js @@ -24,11 +24,11 @@ let lastUsedThenable: Thenable | null = null; const MAX_AD_HOC_SUSPEND_COUNT = 50; -export function isTrackingSuspendedThenable() { +export function isTrackingSuspendedThenable(): boolean { return suspendedThenable !== null; } -export function suspendedThenableDidResolve() { +export function suspendedThenableDidResolve(): boolean { if (suspendedThenable !== null) { const status = suspendedThenable.status; return status === 'fulfilled' || status === 'rejected'; diff --git a/packages/react-reconciler/src/ReactFiberWakeable.old.js b/packages/react-reconciler/src/ReactFiberWakeable.old.js index e494aa34fc1f2..11f470cfab888 100644 --- a/packages/react-reconciler/src/ReactFiberWakeable.old.js +++ b/packages/react-reconciler/src/ReactFiberWakeable.old.js @@ -24,11 +24,11 @@ let lastUsedThenable: Thenable | null = null; const MAX_AD_HOC_SUSPEND_COUNT = 50; -export function isTrackingSuspendedThenable() { +export function isTrackingSuspendedThenable(): boolean { return suspendedThenable !== null; } -export function suspendedThenableDidResolve() { +export function suspendedThenableDidResolve(): boolean { if (suspendedThenable !== null) { const status = suspendedThenable.status; return status === 'fulfilled' || status === 'rejected'; diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.new.js b/packages/react-reconciler/src/ReactFiberWorkLoop.new.js index ca6bbcae278ab..ccd1821db2c90 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.new.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.new.js @@ -357,7 +357,7 @@ let workInProgressRootRenderTargetTime: number = Infinity; const RENDER_TIMEOUT_MS = 500; let workInProgressTransitions: Array | null = null; -export function getWorkInProgressTransitions() { +export function getWorkInProgressTransitions(): null | Array { return workInProgressTransitions; } @@ -814,7 +814,7 @@ export function scheduleInitialHydrationOnRoot( ensureRootIsScheduled(root, eventTime); } -export function isUnsafeClassRenderPhaseUpdate(fiber: Fiber) { +export function isUnsafeClassRenderPhaseUpdate(fiber: Fiber): boolean { // Check if this is a render phase update. Only called by class components, // which special (deprecated) behavior for UNSAFE_componentWillReceive props. return ( @@ -1557,7 +1557,7 @@ declare function flushSync(fn: () => R): R; // eslint-disable-next-line no-redeclare declare function flushSync(): void; // eslint-disable-next-line no-redeclare -export function flushSync(fn) { +export function flushSync(fn): void { // In legacy mode, we flush pending passive effects at the beginning of the // next event, not at the end of the previous one. if ( @@ -1596,7 +1596,7 @@ export function flushSync(fn) { } } -export function isAlreadyRendering() { +export function isAlreadyRendering(): boolean { // Used by the renderer to print a warning if certain APIs are called from // the wrong context. return ( diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.old.js b/packages/react-reconciler/src/ReactFiberWorkLoop.old.js index 4715d3fdf4df9..dc592a912e3a1 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.old.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.old.js @@ -357,7 +357,7 @@ let workInProgressRootRenderTargetTime: number = Infinity; const RENDER_TIMEOUT_MS = 500; let workInProgressTransitions: Array | null = null; -export function getWorkInProgressTransitions() { +export function getWorkInProgressTransitions(): null | Array { return workInProgressTransitions; } @@ -814,7 +814,7 @@ export function scheduleInitialHydrationOnRoot( ensureRootIsScheduled(root, eventTime); } -export function isUnsafeClassRenderPhaseUpdate(fiber: Fiber) { +export function isUnsafeClassRenderPhaseUpdate(fiber: Fiber): boolean { // Check if this is a render phase update. Only called by class components, // which special (deprecated) behavior for UNSAFE_componentWillReceive props. return ( @@ -1557,7 +1557,7 @@ declare function flushSync(fn: () => R): R; // eslint-disable-next-line no-redeclare declare function flushSync(): void; // eslint-disable-next-line no-redeclare -export function flushSync(fn) { +export function flushSync(fn): void { // In legacy mode, we flush pending passive effects at the beginning of the // next event, not at the end of the previous one. if ( @@ -1596,7 +1596,7 @@ export function flushSync(fn) { } } -export function isAlreadyRendering() { +export function isAlreadyRendering(): boolean { // Used by the renderer to print a warning if certain APIs are called from // the wrong context. return ( diff --git a/packages/react-reconciler/src/clz32.js b/packages/react-reconciler/src/clz32.js index 80a9cfb911482..fe827c4ca0870 100644 --- a/packages/react-reconciler/src/clz32.js +++ b/packages/react-reconciler/src/clz32.js @@ -9,7 +9,9 @@ // TODO: This is pretty well supported by browsers. Maybe we can drop it. -export const clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; +export const clz32: (x: number) => number = Math.clz32 + ? Math.clz32 + : clz32Fallback; // Count leading zeros. // Based on: diff --git a/packages/react-refresh/src/ReactFreshRuntime.js b/packages/react-refresh/src/ReactFreshRuntime.js index 99d4d03199d70..56af77a8e8584 100644 --- a/packages/react-refresh/src/ReactFreshRuntime.js +++ b/packages/react-refresh/src/ReactFreshRuntime.js @@ -599,13 +599,13 @@ export function injectIntoGlobalHook(globalObject: any): void { } } -export function hasUnrecoverableErrors() { +export function hasUnrecoverableErrors(): boolean { // TODO: delete this after removing dependency in RN. return false; } // Exposed for testing. -export function _getMountedRootCount() { +export function _getMountedRootCount(): number { if (__DEV__) { return mountedRoots.size; } else { diff --git a/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js b/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js index 737a8502801bb..3182d1ab16cdf 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js +++ b/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js @@ -94,7 +94,7 @@ export async function getSource( url: string, context: GetSourceContext, defaultGetSource: GetSourceFunction, -) { +): Promise<{source: Source}> { // We stash this in case we end up needing to resolve export * statements later. stashedGetSource = defaultGetSource; return defaultGetSource(url, context, defaultGetSource); diff --git a/packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js b/packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js index 98d3058029fc5..bbc26b6c84f83 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js +++ b/packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js @@ -29,7 +29,7 @@ class ClientReferenceDependency extends ModuleDependency { super(request); } - get type() { + get type(): string { return 'client-reference'; } } diff --git a/packages/react-server/src/ReactFizzContext.js b/packages/react-server/src/ReactFizzContext.js index 3834a6f1076ff..005fb776fed05 100644 --- a/packages/react-server/src/ReactFizzContext.js +++ b/packages/react-server/src/ReactFizzContext.js @@ -17,7 +17,8 @@ if (__DEV__) { warnedAboutMissingGetChildContext = {}; } -export const emptyContextObject = {}; +// $FlowFixMe[incompatible-exact] +export const emptyContextObject: {} = {}; if (__DEV__) { Object.freeze(emptyContextObject); } diff --git a/packages/react-server/src/ReactFizzHooks.js b/packages/react-server/src/ReactFizzHooks.js index de67ccebcaf6b..f6c8847a81b2d 100644 --- a/packages/react-server/src/ReactFizzHooks.js +++ b/packages/react-server/src/ReactFizzHooks.js @@ -239,13 +239,13 @@ export function finishHooks( return children; } -export function getThenableStateAfterSuspending() { +export function getThenableStateAfterSuspending(): null | ThenableState { const state = thenableState; thenableState = null; return state; } -export function checkDidRenderIdHook() { +export function checkDidRenderIdHook(): boolean { // This should be called immediately after every finishHooks call. // Conceptually, it's part of the return value of finishHooks; it's only a // separate function to avoid using an array tuple. diff --git a/packages/react-server/src/ReactFlightHooks.js b/packages/react-server/src/ReactFlightHooks.js index dfb234b15ad27..c2d319074e7f8 100644 --- a/packages/react-server/src/ReactFlightHooks.js +++ b/packages/react-server/src/ReactFlightHooks.js @@ -39,7 +39,7 @@ export function prepareToUseHooksForComponent( thenableState = prevThenableState; } -export function getThenableStateAfterSuspending() { +export function getThenableStateAfterSuspending(): null | ThenableState { const state = thenableState; thenableState = null; return state; diff --git a/packages/react/src/BadMapPolyfill.js b/packages/react/src/BadMapPolyfill.js index 9cad26144490e..89615303ce4e5 100644 --- a/packages/react/src/BadMapPolyfill.js +++ b/packages/react/src/BadMapPolyfill.js @@ -6,7 +6,7 @@ * @flow */ -export let hasBadMapPolyfill; +export let hasBadMapPolyfill: boolean; if (__DEV__) { hasBadMapPolyfill = false; diff --git a/packages/scheduler/src/forks/SchedulerPostTask.js b/packages/scheduler/src/forks/SchedulerPostTask.js index 8169bf1acc945..36074d5a97c39 100644 --- a/packages/scheduler/src/forks/SchedulerPostTask.js +++ b/packages/scheduler/src/forks/SchedulerPostTask.js @@ -59,7 +59,7 @@ let currentPriorityLevel_DEPRECATED = NormalPriority; // `isInputPending` is not available. Since we have no way of knowing if // there's pending input, always yield at the end of the frame. -export function unstable_shouldYield() { +export function unstable_shouldYield(): boolean { return getCurrentTime() >= deadline; } diff --git a/packages/shared/CheckStringCoercion.js b/packages/shared/CheckStringCoercion.js index e8fbf64a99b88..a6c72c4bbe77a 100644 --- a/packages/shared/CheckStringCoercion.js +++ b/packages/shared/CheckStringCoercion.js @@ -73,7 +73,7 @@ function testStringCoercion(value: mixed) { export function checkAttributeStringCoercion( value: mixed, attributeName: string, -) { +): void | string { if (__DEV__) { if (willCoercionThrow(value)) { console.error( @@ -87,7 +87,7 @@ export function checkAttributeStringCoercion( } } -export function checkKeyStringCoercion(value: mixed) { +export function checkKeyStringCoercion(value: mixed): void | string { if (__DEV__) { if (willCoercionThrow(value)) { console.error( @@ -100,7 +100,10 @@ export function checkKeyStringCoercion(value: mixed) { } } -export function checkPropStringCoercion(value: mixed, propName: string) { +export function checkPropStringCoercion( + value: mixed, + propName: string, +): void | string { if (__DEV__) { if (willCoercionThrow(value)) { console.error( @@ -114,7 +117,10 @@ export function checkPropStringCoercion(value: mixed, propName: string) { } } -export function checkCSSPropertyStringCoercion(value: mixed, propName: string) { +export function checkCSSPropertyStringCoercion( + value: mixed, + propName: string, +): void | string { if (__DEV__) { if (willCoercionThrow(value)) { console.error( @@ -128,7 +134,7 @@ export function checkCSSPropertyStringCoercion(value: mixed, propName: string) { } } -export function checkHtmlStringCoercion(value: mixed) { +export function checkHtmlStringCoercion(value: mixed): void | string { if (__DEV__) { if (willCoercionThrow(value)) { console.error( @@ -141,7 +147,7 @@ export function checkHtmlStringCoercion(value: mixed) { } } -export function checkFormFieldValueStringCoercion(value: mixed) { +export function checkFormFieldValueStringCoercion(value: mixed): void | string { if (__DEV__) { if (willCoercionThrow(value)) { console.error( diff --git a/packages/shared/ReactErrorUtils.js b/packages/shared/ReactErrorUtils.js index ae344d302f441..5a33bfceae1c0 100644 --- a/packages/shared/ReactErrorUtils.js +++ b/packages/shared/ReactErrorUtils.js @@ -105,7 +105,7 @@ export function rethrowCaughtError() { } } -export function hasCaughtError() { +export function hasCaughtError(): boolean { return hasError; } diff --git a/packages/shared/ReactSymbols.js b/packages/shared/ReactSymbols.js index 50f4fba27d98a..c68e50d5c693e 100644 --- a/packages/shared/ReactSymbols.js +++ b/packages/shared/ReactSymbols.js @@ -12,28 +12,36 @@ // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' // The Symbol used to tag the ReactElement-like types. -export const REACT_ELEMENT_TYPE = Symbol.for('react.element'); -export const REACT_PORTAL_TYPE = Symbol.for('react.portal'); -export const REACT_FRAGMENT_TYPE = Symbol.for('react.fragment'); -export const REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode'); -export const REACT_PROFILER_TYPE = Symbol.for('react.profiler'); -export const REACT_PROVIDER_TYPE = Symbol.for('react.provider'); -export const REACT_CONTEXT_TYPE = Symbol.for('react.context'); -export const REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context'); -export const REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref'); -export const REACT_SUSPENSE_TYPE = Symbol.for('react.suspense'); -export const REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list'); -export const REACT_MEMO_TYPE = Symbol.for('react.memo'); -export const REACT_LAZY_TYPE = Symbol.for('react.lazy'); -export const REACT_SCOPE_TYPE = Symbol.for('react.scope'); -export const REACT_DEBUG_TRACING_MODE_TYPE = Symbol.for( +export const REACT_ELEMENT_TYPE: symbol = Symbol.for('react.element'); +export const REACT_PORTAL_TYPE: symbol = Symbol.for('react.portal'); +export const REACT_FRAGMENT_TYPE: symbol = Symbol.for('react.fragment'); +export const REACT_STRICT_MODE_TYPE: symbol = Symbol.for('react.strict_mode'); +export const REACT_PROFILER_TYPE: symbol = Symbol.for('react.profiler'); +export const REACT_PROVIDER_TYPE: symbol = Symbol.for('react.provider'); +export const REACT_CONTEXT_TYPE: symbol = Symbol.for('react.context'); +export const REACT_SERVER_CONTEXT_TYPE: symbol = Symbol.for( + 'react.server_context', +); +export const REACT_FORWARD_REF_TYPE: symbol = Symbol.for('react.forward_ref'); +export const REACT_SUSPENSE_TYPE: symbol = Symbol.for('react.suspense'); +export const REACT_SUSPENSE_LIST_TYPE: symbol = Symbol.for( + 'react.suspense_list', +); +export const REACT_MEMO_TYPE: symbol = Symbol.for('react.memo'); +export const REACT_LAZY_TYPE: symbol = Symbol.for('react.lazy'); +export const REACT_SCOPE_TYPE: symbol = Symbol.for('react.scope'); +export const REACT_DEBUG_TRACING_MODE_TYPE: symbol = Symbol.for( 'react.debug_trace_mode', ); -export const REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen'); -export const REACT_LEGACY_HIDDEN_TYPE = Symbol.for('react.legacy_hidden'); -export const REACT_CACHE_TYPE = Symbol.for('react.cache'); -export const REACT_TRACING_MARKER_TYPE = Symbol.for('react.tracing_marker'); -export const REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED = Symbol.for( +export const REACT_OFFSCREEN_TYPE: symbol = Symbol.for('react.offscreen'); +export const REACT_LEGACY_HIDDEN_TYPE: symbol = Symbol.for( + 'react.legacy_hidden', +); +export const REACT_CACHE_TYPE: symbol = Symbol.for('react.cache'); +export const REACT_TRACING_MARKER_TYPE: symbol = Symbol.for( + 'react.tracing_marker', +); +export const REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED: symbol = Symbol.for( 'react.default_value', ); diff --git a/packages/shared/forks/ReactFeatureFlags.www-dynamic.js b/packages/shared/forks/ReactFeatureFlags.www-dynamic.js index 520b102b7d3fc..67812e36dae55 100644 --- a/packages/shared/forks/ReactFeatureFlags.www-dynamic.js +++ b/packages/shared/forks/ReactFeatureFlags.www-dynamic.js @@ -19,7 +19,7 @@ export const enableFilterEmptyStringAttributesDOM = __VARIANT__; export const enableLegacyFBSupport = __VARIANT__; export const skipUnmountedBoundaries = __VARIANT__; export const enableUseRefAccessWarning = __VARIANT__; -export const deletedTreeCleanUpLevel = __VARIANT__ ? 3 : 1; +export const deletedTreeCleanUpLevel: number = __VARIANT__ ? 3 : 1; export const enableProfilerNestedUpdateScheduledHook = __VARIANT__; export const disableSchedulerTimeoutInWorkLoop = __VARIANT__; export const enableLazyContextPropagation = __VARIANT__; diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js index 2c59dde3a11b6..18a333e40f769 100644 --- a/packages/shared/forks/ReactFeatureFlags.www.js +++ b/packages/shared/forks/ReactFeatureFlags.www.js @@ -39,13 +39,13 @@ export const { // On WWW, __EXPERIMENTAL__ is used for a new modern build. // It's not used anywhere in production yet. -export const enableStrictEffects = +export const enableStrictEffects: boolean = __DEV__ && dynamicFeatureFlags.enableStrictEffects; export const debugRenderPhaseSideEffectsForStrictMode = __DEV__; export const enableProfilerTimer = __PROFILE__; export const enableProfilerCommitHooks = __PROFILE__; export const enableProfilerNestedUpdatePhase = __PROFILE__; -export const enableProfilerNestedUpdateScheduledHook = +export const enableProfilerNestedUpdateScheduledHook: boolean = __PROFILE__ && dynamicFeatureFlags.enableProfilerNestedUpdateScheduledHook; export const enableUpdaterTracking = __PROFILE__; @@ -57,7 +57,7 @@ export const enableUseHook = true; export const enableUseMemoCacheHook = true; // Logs additional User Timing API marks for use with an experimental profiling tool. -export const enableSchedulingProfiler = +export const enableSchedulingProfiler: boolean = __PROFILE__ && dynamicFeatureFlags.enableSchedulingProfiler; // Note: we'll want to remove this when we to userland implementation. diff --git a/packages/shared/isValidElementType.js b/packages/shared/isValidElementType.js index c0e4cdc769323..d2b4602de22b1 100644 --- a/packages/shared/isValidElementType.js +++ b/packages/shared/isValidElementType.js @@ -35,7 +35,7 @@ import { const REACT_MODULE_REFERENCE: symbol = Symbol.for('react.module.reference'); -export default function isValidElementType(type: mixed) { +export default function isValidElementType(type: mixed): boolean { if (typeof type === 'string' || typeof type === 'function') { return true; }