Update Flow to 0.267 (#34272)

Changes to type inference require some more annotations.
This commit is contained in:
Jan Kassens 2025-08-22 15:53:07 -04:00 committed by GitHub
parent 05addfc663
commit 06cfa99f37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 26 additions and 26 deletions

View File

@ -74,8 +74,8 @@
"eslint-plugin-react-internal": "link:./scripts/eslint-rules",
"fbjs-scripts": "^3.0.1",
"filesize": "^6.0.1",
"flow-bin": "^0.266",
"flow-remove-types": "^2.266",
"flow-bin": "^0.267",
"flow-remove-types": "^2.267",
"flow-typed": "^4.1.1",
"glob": "^7.1.6",
"glob-stream": "^6.1.0",

View File

@ -1317,9 +1317,9 @@ export function attach(
if (componentLogsEntry === undefined) {
componentLogsEntry = {
errors: new Map(),
errorsCount: 0,
errorsCount: 0 as number,
warnings: new Map(),
warningsCount: 0,
warningsCount: 0 as number,
};
fiberToComponentLogsMap.set(fiber, componentLogsEntry);
}

View File

@ -118,9 +118,9 @@ export function attach(
if (componentLogsEntry === undefined) {
componentLogsEntry = {
errors: new Map(),
errorsCount: 0,
errorsCount: 0 as number,
warnings: new Map(),
warningsCount: 0,
warningsCount: 0 as number,
};
componentInfoToComponentLogsMap.set(componentInfo, componentLogsEntry);
}

View File

@ -488,7 +488,7 @@ function recursivelyInsertNewFiber(
const viewTransitionState: ViewTransitionState = finishedWork.stateNode;
// TODO: If this was already cloned by a previous pass we can reuse those clones.
viewTransitionState.clones = null;
let nextPhase;
let nextPhase: VisitPhase;
if (visitPhase === INSERT_EXIT) {
// This was an Enter of a ViewTransition. We now move onto inserting the inner
// HostComponents and finding inner pairs.
@ -637,7 +637,7 @@ function recursivelyInsertClonesFromExistingTree(
// So we need it to be cleared before we do that.
// TODO: Use some other temporary state to track this.
child.flags &= ~Update;
let nextPhase;
let nextPhase: VisitPhase;
if (visitPhase === CLONE_EXIT) {
// This was an Enter of a ViewTransition. We now move onto unhiding the inner
// HostComponents and finding inner pairs.
@ -894,7 +894,7 @@ function insertDestinationClonesOfFiber(
// Only insert clones if this tree is going to be visible. No need to
// clone invisible content.
// TODO: If this is visible but detached it should still be cloned.
let nextPhase;
let nextPhase: VisitPhase;
if (visitPhase === CLONE_UPDATE && (flags & Visibility) !== NoFlags) {
// This is the root of an appear. We need to trigger Enter transitions.
nextPhase = CLONE_EXIT;
@ -922,7 +922,7 @@ function insertDestinationClonesOfFiber(
const viewTransitionState: ViewTransitionState = finishedWork.stateNode;
// TODO: If this was already cloned by a previous pass we can reuse those clones.
viewTransitionState.clones = null;
let nextPhase;
let nextPhase: VisitPhase;
if (visitPhase === CLONE_EXIT) {
// This was an Enter of a ViewTransition. We now move onto unhiding the inner
// HostComponents and finding inner pairs.

View File

@ -25,7 +25,7 @@ const AbortControllerLocal: typeof AbortController =
function AbortControllerShim() {
const listeners = [];
const signal = (this.signal = {
aborted: false,
aborted: false as boolean,
addEventListener: (type, listener) => {
listeners.push(listener);
},

View File

@ -1208,7 +1208,7 @@ function useMemoCache(size: number): Array<mixed> {
? currentMemoCache.data
: // Clone the memo cache before each render (copy-on-write)
currentMemoCache.data.map(array => array.slice()),
index: 0,
index: 0 as number,
};
}
}
@ -1218,7 +1218,7 @@ function useMemoCache(size: number): Array<mixed> {
if (memoCache == null) {
memoCache = {
data: [],
index: 0,
index: 0 as number,
};
}
if (updateQueue === null) {

View File

@ -1060,7 +1060,7 @@ export function performWorkOnRoot(
// even for regular pings.
checkIfRootIsPrerendering(root, lanes);
let exitStatus = shouldTimeSlice
let exitStatus: RootExitStatus = shouldTimeSlice
? renderRootConcurrent(root, lanes)
: renderRootSync(root, lanes, true);
@ -1212,7 +1212,7 @@ function recoverFromConcurrentError(
root: FiberRoot,
originallyAttemptedLanes: Lanes,
errorRetryLanes: Lanes,
) {
): RootExitStatus {
// If an error occurred during hydration, discard server response and fall
// back to client side render.
@ -2520,7 +2520,7 @@ function workLoopSync() {
}
}
function renderRootConcurrent(root: FiberRoot, lanes: Lanes) {
function renderRootConcurrent(root: FiberRoot, lanes: Lanes): RootExitStatus {
const prevExecutionContext = executionContext;
executionContext |= RenderContext;
const prevDispatcher = pushDispatcher(root.containerInfo);

View File

@ -556,7 +556,7 @@ function createModelResolver<T>(
}
} else {
blocked = initializingChunkBlockedModel = {
deps: cyclic ? 0 : 1,
deps: (cyclic ? 0 : 1) as number,
value: (null: any),
};
}

View File

@ -283,7 +283,7 @@ function unstable_runWithPriority<T>(
}
function unstable_next<T>(eventHandler: () => T): T {
var priorityLevel;
var priorityLevel: PriorityLevel;
switch (currentPriorityLevel) {
case ImmediatePriority:
case UserBlockingPriority:

View File

@ -286,7 +286,7 @@ function unstable_runWithPriority<T>(
}
function unstable_next<T>(eventHandler: () => T): T {
var priorityLevel;
var priorityLevel: PriorityLevel;
switch (currentPriorityLevel) {
case ImmediatePriority:
case UserBlockingPriority:

View File

@ -196,7 +196,7 @@ export function unstable_getCurrentPriorityLevel(): PriorityLevel {
}
export function unstable_next<T>(callback: () => T): T {
let priorityLevel;
let priorityLevel: PriorityLevel;
switch (currentPriorityLevel_DEPRECATED) {
case ImmediatePriority:
case UserBlockingPriority:

View File

@ -19,7 +19,7 @@ const COMPLEX_ARRAY = 1;
const PRIMITIVE_ARRAY = 2; // Primitive values only
const ENTRIES_ARRAY = 3; // Tuple arrays of string and value (like Headers, Map, etc)
function getArrayKind(array: Object): 0 | 1 | 2 | 3 {
let kind = EMPTY_ARRAY;
let kind: 0 | 1 | 2 | 3 = EMPTY_ARRAY;
for (let i = 0; i < array.length; i++) {
const value = array[i];
if (typeof value === 'object' && value !== null) {

View File

@ -9298,12 +9298,12 @@ flatted@^3.2.9:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.1.tgz#21db470729a6734d4997002f439cb308987f567a"
integrity sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==
flow-bin@^0.266:
version "0.266.1"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.266.1.tgz#8939be6fbd681c4ef8dc4873b22f4b79be76cb0a"
integrity sha512-c1lg1E8SDcuPSkrOeH0JTcNKMZOzXvqX2DuuXJ0amZec15uyuIi8QlGTO3OzYssMT/kwFdo5vviJqSUI/BNFbw==
flow-bin@^0.267:
version "0.267.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.267.0.tgz#a191375df35c768f1afaebfd0e25b06c8ab82a04"
integrity sha512-NsBcxdAqQauzgOaDf960M+eEnjcFS6FeMs93dEpkvQflwMlP4SRMdKQR8p5WzJJh07CXq9iQnxn+JjLN6kaLUw==
flow-remove-types@^2.266:
flow-remove-types@^2.267:
version "2.279.0"
resolved "https://registry.yarnpkg.com/flow-remove-types/-/flow-remove-types-2.279.0.tgz#3a3388d9158eba0f82c40d80d31d9640b883a3f5"
integrity sha512-bPFloMR/A2b/r/sIsf7Ix0LaMicCJNjwhXc4xEEQVzJCIz5u7C7XDaEOXOiqveKlCYK7DcBNn6R01Cbbc9gsYA==