Skip to content
5 changes: 3 additions & 2 deletions src/extensions/core/groupNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ export class GroupNodeConfig {
}

getNodeDef(
node: GroupNodeData
node: GroupNodeData | GroupNodeWorkflowData['nodes'][number]
): GroupNodeDef | ComfyNodeDef | null | undefined {
if (node.type) {
const def = globalDefs[node.type]
Expand All @@ -386,7 +386,8 @@ export class GroupNodeConfig {
let type: string | number | null = linksFrom[0]?.[0]?.[5] ?? null
if (type === 'COMBO') {
// Use the array items
const source = node.outputs?.[0]?.widget?.name
const output = node.outputs?.[0] as GroupNodeOutput | undefined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using type assertions isn't much safer than any

const source = output?.widget?.name
Comment on lines +389 to +390
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Type assertion is necessary due to unknown[] in workflow data.

Since GroupNodeWorkflowData['nodes'][number]['outputs'] is typed as unknown[], the cast to GroupNodeOutput | undefined is needed to access the widget property. The guarded access pattern (output?.widget?.name) is safer than the previous direct chain access.

Consider whether the outputs type in GroupNodeWorkflowData could be narrowed to GroupNodeOutput[] to eliminate this cast, though that may require broader changes.

🤖 Prompt for AI Agents
In `@src/extensions/core/groupNode.ts` around lines 389 - 390, The code currently
casts node.outputs?.[0] to GroupNodeOutput | undefined because
GroupNodeWorkflowData['nodes'][number]['outputs'] is typed as unknown[]; keep
this explicit cast (const output = node.outputs?.[0] as GroupNodeOutput |
undefined) and the guarded access (const source = output?.widget?.name) to avoid
runtime errors when accessing widget, and if feasible consider narrowing the
outputs type in GroupNodeWorkflowData to GroupNodeOutput[] across the workflow
typings to remove the need for the cast.

const nodeIdx = linksFrom[0]?.[0]?.[2]
if (source && nodeIdx != null) {
const fromTypeName = this.nodeData.nodes[Number(nodeIdx)]?.type
Expand Down
Loading