Skip to content
Merged
Prev Previous commit
Next Next commit
make type gaurd syntax
  • Loading branch information
christian-byrne committed Dec 13, 2025
commit d18a9c73a3a3968c100e96d63c74b54cc651acac
15 changes: 13 additions & 2 deletions src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1499,8 +1499,19 @@ export class ComfyApp {
}

// @deprecated
isApiJson(data: unknown) {
return _.isObject(data) && Object.values(data).every((v) => v.class_type)
isApiJson(data: unknown): data is ComfyApiWorkflow {
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

Remove @deprecated tag or provide migration path.

The method is marked as deprecated but is actively used in the new prompt-handling code (line 1475). Either remove the deprecation tag if the method is still needed, or provide an alternative and update the calling code.

🤖 Prompt for AI Agents
In src/scripts/app.ts around line 1502, the type-guard method isApiJson is
marked @deprecated but is still used by the new prompt-handling code (caller at
~line 1475); remove the @deprecated annotation if this API is intended to
remain, or instead add/implement the recommended replacement function and update
the caller(s) to use that new API; ensure the signature/behavior matches the
caller expectations (or adjust the caller) and update any JSDoc/tsdoc to reflect
the chosen migration path.

if (!_.isObject(data) || Array.isArray(data)) {
return false
}

return Object.values(data).every((node) => {
if (!node || typeof node !== 'object' || Array.isArray(node)) {
return false
}

const { class_type: classType, inputs } = node as Record<string, unknown>
return typeof classType === 'string' && _.isObject(inputs)
})
}

loadApiJson(apiData: ComfyApiWorkflow, fileName: string) {
Expand Down
Loading