Comfy-Org / Comfy-Org/ComfyUI_frontend

[Bug]: `comfyui-frontend-types` no longer compatible with `@comfyorg/litegraph` ?

Open
#5,033 5 comments 0 reactions 0 assignees View on GitHub
Potential Bug
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

### Prerequisites

- [x] I am running the latest version of ComfyUI
- [x] I have searched existing issues to make sure this isn't a duplicate
- [x] I have tested with all custom nodes disabled ([see how](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled))

### What happened?

Perhaps I just have something misconfigured in the TypeScript options, but after updating the types I am now getting a lot of conflicts between imported types from `@comfyorg/litegraph` no longer compatible with local (but not exported) types in `@comfyorg/comfyui-frontend-types`. It looks intentional as the it looks like it's because of a branching and addition of a `#private;` field to both the types in `@comfyorg/litegraph` and `@comfyorg/comfyui-frontend-types` but the compiler errors since these specific cannot be equal.

For instance, this is now an error:

```ts
import type {LGraph} from "@comfyorg/litegraph";
import type {ComfyApp} from "@comfyorg/comfyui-frontend-types";

function getGraph(app: ComfyApp) : LGraph {
return app.graph; // Error here, as ComfyApp.graph's LGraph is not compatible with LiteGraph's LGraph because of a #private; field.
}
```
With the error:
> Property '#private' in type 'LGraph' refers to a different member that cannot be accessed from within type 'LGraph'

comfyui-frontend-types doesn't export these types, so there's no way to import many of them. While we could make aliases off of some, it cannot be done for others. Take this issue:

```ts
import type {LLink} from "@comfyorg/litegraph";
import type {ComfyApp} from "@comfyorg/frontend";

type LGraph = ComfyApp['graph'];

function getLinks(app: ComfyApp) : LLink | null {
const graph: LGraph = app.graph; // No longer error here because of the LGraph alias type above.
return graph.links.get(0) ?? null; // However, error here because graph.link's LLink is not compatible with LitGraphs' LLink type because of a #private; field.
}
```

For the last example, there's no way to import the type version for ComfyApp's LGraph's LLinks at all since it's not exported by comfyui-frontend-types and not easily accessible otherwise.

How can we get around this?

### Steps to Reproduce

N/a

### How is this affecting you?

Minor inconvenience

### ComfyUI Frontend Version

latest

### Browser

Chrome/Chromium

### Console Errors

```javascript

```

### Logs

```shell

```

### Additional Context

_No response_

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-5033-Bug-comfyui-frontend-types-no-longer-compatible-with-comfyorg-litegraph-2516d73d3650810f9c0fceae0c946165) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Research direction

Start by comparing the declarations exposed by @comfyorg/litegraph with the local, non-exported types used by @comfyorg/comfyui-frontend-types, focusing on LGraph and LLink. Reproduce the shown ComfyApp.graph assignments with TypeScript and determine whether the types can be made compatible or exported; done means the examples compile without the private-member conflicts.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.