ComfyUI_frontend icon indicating copy to clipboard operation
ComfyUI_frontend copied to clipboard

[Feature Request]: Typescript - typing doesn't allow custom messages in ComfyApi.addEventListener (improvement / not blocking)

Open pterrien opened this issue 11 months ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and checked the recent builds/commits

What would your feature do ?

Hello,

Opened a feature, as many people will not be impacted, and this does not prevent the frontend to work of course.

@comfyorg/comfyui-frontend-types version: 1.6.8

When trying to add an API event listener:

api.addEventListener('my-custom-event', (event) => {
	...
})

I get the following TS error: Argument of type '"my-custom-event"' is not assignable to parameter of type 'keyof ApiCalls'. ApiCalls being defined as follows, in source api.ts file (line 68):

interface ApiCalls extends BackendApiCalls, FrontendApiCalls {}

Of course, mapping my custom message type to any is an obvious - yet a bit ugly - workaround.

So no big revolution, just a small enhancement I guess.

Hope this helps, cheers.

Proposed workflow

N/A

Additional information

No response

┆Issue is synchronized with this Notion page by Unito

pterrien avatar Dec 29 '24 11:12 pterrien

Additionally, having the types for the backend event messages (StatusWsMessageStatus, ...) could be nice IMO. Not mandatory of course, except maybe one: ExecutedWsMessage Because people are allowed to send custom data when the python method returns something like:

 return { "ui":a_new_dictionary, "result": the_tuple_of_output_values }

So, to do things properly, we should be able to define our own custom message, by extending ExecutedWsMessage.

pterrien avatar Dec 30 '24 10:12 pterrien