@@ -372,10 +372,10 @@ export function isUpdateQueue<S>(value: unknown): value is UpdateQueue<S> {
372372 * @throws Error if updateQueue is null
373373 */
374374export function assertUpdateQueue < S > ( hook : Hook ) : UpdateQueue < S > {
375- if ( hook . queue === null ) {
376- throw new Error ( "Hook queue is null " ) ;
375+ if ( ! isUpdateQueue < S > ( hook . queue ) ) {
376+ throw new Error ( "Hook queue is not a valid UpdateQueue " ) ;
377377 }
378- return hook . queue as UpdateQueue < S > ;
378+ return hook . queue ;
379379}
380380
381381// ============================================
@@ -446,14 +446,14 @@ export function isFlagsEmpty(flags: Flags): boolean {
446446 * Type guard for Element.
447447 */
448448export function isElement ( node : Node ) : node is Element {
449- return node . nodeType === Node . ELEMENT_NODE ;
449+ return typeof Node !== "undefined" && node . nodeType === Node . ELEMENT_NODE ;
450450}
451451
452452/**
453453 * Type guard for Text node.
454454 */
455455export function isTextNode ( node : Node ) : node is Text {
456- return node . nodeType === Node . TEXT_NODE ;
456+ return typeof Node !== "undefined" && node . nodeType === Node . TEXT_NODE ;
457457}
458458
459459/**
@@ -616,7 +616,13 @@ export function isMemoComponent(value: unknown): value is MemoComponent {
616616 return false ;
617617 }
618618 const obj = value as Record < string , unknown > ;
619- return "$$typeof" in obj && typeof obj [ "$$typeof" ] === "symbol" ;
619+ return (
620+ "$$typeof" in obj &&
621+ typeof obj [ "$$typeof" ] === "symbol" &&
622+ "type" in obj &&
623+ obj [ "type" ] !== undefined &&
624+ ( typeof obj [ "compare" ] === "function" || obj [ "compare" ] === null )
625+ ) ;
620626}
621627
622628/**
0 commit comments