Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the missing @flow annotation #12764

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactCapturedValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {getStackAddendumByWorkInProgressFiber} from 'shared/ReactFiberComponentT

export type CapturedValue<T> = {
value: T,
source: Fiber | null,
source: Fiber,
stack: string | null,
};

Expand All @@ -29,7 +29,7 @@ export type CapturedError = {

export function createCapturedValue<T>(
value: T,
source: Fiber | null,
source: Fiber,
): CapturedValue<T> {
// If the value is an error, call this function immediately after it is thrown
// so the stack is accurate.
Expand Down
5 changes: 3 additions & 2 deletions packages/react-reconciler/src/ReactFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

import type {ReactElement, Source} from 'shared/ReactElementType';
import type {ReactPortal, RefObject} from 'shared/ReactTypes';
import type {ReactFragment, ReactPortal, RefObject} from 'shared/ReactTypes';
import type {TypeOfWork} from 'shared/ReactTypeOfWork';
import type {TypeOfMode} from './ReactTypeOfMode';
import type {TypeOfSideEffect} from 'shared/ReactTypeOfSideEffect';
Expand Down Expand Up @@ -320,7 +321,7 @@ export function createWorkInProgress(
return workInProgress;
}

export function createHostRootFiber(isAsync): Fiber {
export function createHostRootFiber(isAsync: boolean): Fiber {
const mode = isAsync ? AsyncMode | StrictMode : NoContext;
return createFiber(HostRoot, null, null, mode);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/react-reconciler/src/ReactFiberCommitWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import type {HostConfig} from 'react-reconciler';
import type {Fiber} from './ReactFiber';
import type {FiberRoot} from './ReactFiber';
import type {FiberRoot} from './ReactFiberRoot';
import type {ExpirationTime} from './ReactFiberExpirationTime';
import type {CapturedValue, CapturedError} from './ReactCapturedValue';

Expand Down Expand Up @@ -65,7 +65,7 @@ export function logError(boundary: Fiber, errorInfo: CapturedValue<mixed>) {
}

const capturedError: CapturedError = {
componentName: source !== null ? getComponentName(source) : null,
componentName: getComponentName(source),
componentStack: stack !== null ? stack : '',
error: errorInfo.value,
errorBoundary: null,
Expand Down Expand Up @@ -95,7 +95,7 @@ export function logError(boundary: Fiber, errorInfo: CapturedValue<mixed>) {

export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
config: HostConfig<T, P, I, TI, HI, PI, C, CC, CX, PL>,
captureError: (failedFiber: Fiber, error: mixed) => Fiber | null,
captureError: (failedFiber: Fiber, error: mixed) => void,
scheduleWork: (
fiber: Fiber,
startTime: ExpirationTime,
Expand Down
12 changes: 7 additions & 5 deletions packages/react-reconciler/src/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,12 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
}

// Restore the original state of the work-in-progress
assignFiberPropertiesInDEV(
failedUnitOfWork,
stashedWorkInProgressProperties,
);
if (stashedWorkInProgressProperties !== null) {
assignFiberPropertiesInDEV(
failedUnitOfWork,
stashedWorkInProgressProperties,
);
}
switch (failedUnitOfWork.tag) {
case HostRoot:
popHostContainer(failedUnitOfWork);
Expand Down Expand Up @@ -1078,7 +1080,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
}

if (__DEV__ && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
const failedUnitOfWork = nextUnitOfWork;
const failedUnitOfWork: Fiber = nextUnitOfWork;
replayUnitOfWork(failedUnitOfWork, thrownValue, isAsync);
}

Expand Down
6 changes: 5 additions & 1 deletion packages/react-reconciler/src/ReactStrictModeWarnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ if (__DEV__) {
pendingUnsafeLifecycleWarnings = new Map();
};

const getStrictRoot = (fiber: Fiber): Fiber => {
const getStrictRoot = (fiber: Fiber | null): Fiber | null => {
let maybeStrictRoot = null;

while (fiber !== null) {
Expand Down Expand Up @@ -227,6 +227,10 @@ if (__DEV__) {
) => {
const strictRoot = getStrictRoot(fiber);

if (strictRoot === null) {
return;
}

// Dedup strategy: Warn once per component.
// This is difficult to track any other way since component names
// are often vague and are likely to collide between 3rd party libraries.
Expand Down