Comfy-Org / Comfy-Org/ComfyUI_frontend
refactor(litegraph): Properly type LGraph.trigger() actions and params
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Summary
The `LGraph.trigger()` method currently has a loosened overload signature:
```ts
trigger(action: string, param: unknown): void
```
This overload exists alongside the correctly typed one:
```ts
trigger(action: A, param: LGraphTriggerParam): void
```
The loose overload masks type errors elsewhere in the system where actions and/or params are passed with incorrect types. Removing it forces all call sites to use the correctly discriminated union types, but doing so has a large blast radius across the codebase that is out of scope for the PR that introduced this pattern (#12197).
## Goal
- Remove the `trigger(action: string, param: unknown): void` overload from `LGraph.trigger()`.
- Fix all call sites that currently rely on the loose overload to use the correctly typed `LGraphTriggerAction` / `LGraphTriggerParam` types.
- Ensure the runtime guard (`validTriggerActions` set check + `typeof param === 'object'` guard) aligns with the narrowed compile-time types.
## References
- PR introducing the pattern: #12197
- Relevant comment thread: https://github.com/Comfy-Org/ComfyUI_frontend/pull/12197#discussion_r3260983854
- File: `src/lib/litegraph/src/LGraph.ts`
- Related types: `src/lib/litegraph/src/types/graphTriggers.ts`
## Raised by
@DrJKL
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-12325-refactor-litegraph-Properly-type-LGraph-trigger-actions-and-params-3656d73d365081ab8872f33e112dc074) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.