Remove undefined values from results of unsafeEntriesInvariant

This commit is contained in:
Michael B. Gale
2025-10-01 15:28:56 +01:00
parent d25fa60a90
commit 91a63dc72c
2 changed files with 6 additions and 4 deletions

View File

@@ -1307,7 +1307,7 @@ export function unsafeKeysInvariant<T extends Record<string, any>>(
export function unsafeEntriesInvariant<T extends Record<string, any>>(
object: T,
): Array<[keyof T, Exclude<T[keyof T], undefined>]> {
return Object.entries(object) as Array<
[keyof T, Exclude<T[keyof T], undefined>]
>;
return Object.entries(object).filter(
([_, val]) => val !== undefined,
) as Array<[keyof T, Exclude<T[keyof T], undefined>]>;
}