Skip to content

fix(atoms): make Signal passable to functions accepting ZeduxNode#341

Merged
bowheart merged 1 commit intomasterfrom
josh/signal-template-and-node-generics
Feb 27, 2026
Merged

fix(atoms): make Signal passable to functions accepting ZeduxNode#341
bowheart merged 1 commit intomasterfrom
josh/signal-template-and-node-generics

Conversation

@bowheart
Copy link
Collaborator

Description

The Signal class's generics omit the Params and Template generics from the NodeGenerics accepted by the base ZeduxNode class. This is because Signals don't have Params and Template, but it means that a Signal can't be passed to a function accepting any ZeduxNode without some hacky TS workarounds.

To fix this, Signal needs to require the Params and Template generics. I fixed that. And since this is obnoxious for all consumer code, I've added an AnySignal type helper patterned after AnyAtomInstance &co:

// with the changes in this PR, anything accepting a Signal that only cares about the State would have to do this nonsense:
function acceptsSignal(
  signal: Signal<{
    Events: None;
    Params: undefined;
    State: MyRequiredStateType;
    Template: undefined;
  }>
) { ... }

// `AnySignal` to the rescue:
function acceptsSignal(
  signal: AnySignal<{ State: MyRequiredStateType }>
) { ... }

Add tests that verify existing types still work and these changes are working correctly. Also add tests ensuring all cross-assignments work - e.g. a MappedSignal can be passed anywhere a Signal or ZeduxNode is expected, same for AtomInstance, and a SelectorInstance can be passed anywhere a ZeduxNode is expected. In all cases, the passed node must match on any required generics.

@bowheart bowheart force-pushed the josh/signal-template-and-node-generics branch from 99cc403 to da74de0 Compare February 27, 2026 17:27
@bowheart bowheart force-pushed the josh/signal-template-and-node-generics branch from da74de0 to 7f35897 Compare February 27, 2026 17:32
@bowheart bowheart merged commit a9e6cd1 into master Feb 27, 2026
2 checks passed
@bowheart bowheart deleted the josh/signal-template-and-node-generics branch February 27, 2026 17:35
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.

1 participant