Skip to content

Commit f7cc92d

Browse files
committed
chore: fix again
- isUpdatedQueue now vlaidates all five UpdateQueue<S> fields - isHookState now checks all five Hook properties
1 parent 732d6af commit f7cc92d

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

‎src/fiber/typeGuards.ts‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,13 @@ export function isHookState(value: unknown): value is Hook {
253253
return false;
254254
}
255255
const obj = value as Record<string, unknown>;
256-
return "memoizedState" in obj && "next" in obj && "queue" in obj;
256+
return (
257+
"memoizedState" in obj &&
258+
"baseState" in obj &&
259+
"baseQueue" in obj &&
260+
"queue" in obj &&
261+
"next" in obj
262+
);
257263
}
258264

259265
/**
@@ -264,7 +270,13 @@ export function isEffectState(value: unknown): value is Effect {
264270
return false;
265271
}
266272
const obj = value as Record<string, unknown>;
267-
return "tag" in obj && "create" in obj && "deps" in obj;
273+
return (
274+
"tag" in obj &&
275+
"create" in obj &&
276+
"destroy" in obj &&
277+
"deps" in obj &&
278+
"next" in obj
279+
);
268280
}
269281

270282
/**
@@ -364,7 +376,18 @@ export function isUpdateQueue<S>(value: unknown): value is UpdateQueue<S> {
364376
return false;
365377
}
366378
const obj = value as Record<string, unknown>;
367-
return "pending" in obj && "lanes" in obj && "dispatch" in obj;
379+
return (
380+
"pending" in obj &&
381+
(obj["pending"] === null || typeof obj["pending"] === "object") &&
382+
"lanes" in obj &&
383+
typeof obj["lanes"] === "number" &&
384+
"dispatch" in obj &&
385+
(obj["dispatch"] === null || typeof obj["dispatch"] === "function") &&
386+
"lastRenderedReducer" in obj &&
387+
(obj["lastRenderedReducer"] === null ||
388+
typeof obj["lastRenderedReducer"] === "function") &&
389+
"lastRenderedState" in obj
390+
);
368391
}
369392

370393
/**

0 commit comments

Comments
 (0)