Skip to content

Fix SignalMethods.connect callback return type - #133

Merged
JumpLink merged 1 commit into
mainfrom
fix/signalmethods-connect-return
Jun 30, 2026
Merged

Fix SignalMethods.connect callback return type#133
JumpLink merged 1 commit into
mainfrom
fix/signalmethods-connect-return

Conversation

@JumpLink

Copy link
Copy Markdown
Collaborator

SignalMethods.connect typed its callback return as boolean | undefined. That rejects the most common handler shape — one that returns nothing — because a void-returning function is not assignable to boolean | undefined:

events.connect('changed', () => {
    doSomething(); // returns void -> Type 'void' is not assignable to 'boolean | undefined'
});

Switching to boolean | void accepts both a void-returning handler and one that returns true to stop emission, which matches the imports.signals runtime semantics (only true stops emission — see _signals.js).

Fixed here for now; the file already carries a TODO to upstream SignalMethods into @girs/gjs, where the same type lives — that's a separate change in the types generator.

Validated locally (build:types, prettier:check, validate:types, validate:example) — all green.

Closes #116

SignalMethods.connect typed its callback return as
`boolean | undefined`, which rejected the common case of a handler
that returns nothing — a void-returning function is not assignable
to `boolean | undefined`.

Use `boolean | void` so handlers may return nothing or `true` to
stop emission, matching imports.signals semantics (only `true`
stops emission).

Closes #116

@Totto16 Totto16 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JumpLink
JumpLink merged commit 3a2bfa1 into main Jun 30, 2026
2 checks passed
@JumpLink
JumpLink deleted the fix/signalmethods-connect-return branch June 30, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with SignalMethods.connect

2 participants