Skip to content

Issue with SignalMethods.connect #116

@AmionSky

Description

@AmionSky

SignalMethods.connect's callback return type is incorrect

connect<Name extends keyof S>(sigName: Name, callback: (self: this, ...args: S[Name]) => boolean | undefined): number;

It should probably be: boolean | void or boolean | any or even true | any (though it seems redundant to have or any as a type)
as per the documentation:

If callback returns true, emission will stop and no other handlers will be invoked.

Checked the original implementation that's in gjs, and it really only checks for true:
https://gitlab.gnome.org/GNOME/gjs/-/blob/master/modules/core/_signals.js?ref_type=heads#L134

The thing is, this is in gjs. And seems like it is intended to be in @girs/gjs :

// TODO Move this SignalMethods to ts-for-gir / @girs/gjs

But there is already a slightly different type in @girs/gjs's types:
https://github.com/gjsify/types/blob/87c06b320d4754fbffb4043d9142a089a42a62db/gjs/gjs.d.ts#L370

So.. should it be fixed in gjs and removed from here, or it cannot be fixed there? (idk how the type generation works there)
Or should it just be fixed here (for now).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions