improve type narrowing syntax (#5380)

This commit is contained in:
Christian Byrne
2025-09-06 20:27:44 -07:00
committed by GitHub
parent db37693688
commit 2b8d354862

View File

@@ -235,11 +235,15 @@ export const useGraphNodeManager = (graph: LGraph): GraphNodeManager => {
} }
if (typeof value === 'object') { if (typeof value === 'object') {
// Check if it's a File array // Check if it's a File array
if (Array.isArray(value) && value.every((item) => item instanceof File)) { if (
return value as File[] Array.isArray(value) &&
value.length > 0 &&
value.every((item): item is File => item instanceof File)
) {
return value
} }
// Otherwise it's a generic object // Otherwise it's a generic object
return value as object return value
} }
// If none of the above, return undefined // If none of the above, return undefined
console.warn(`Invalid widget value type: ${typeof value}`, value) console.warn(`Invalid widget value type: ${typeof value}`, value)