Skip to content

fix: preserve signature of observable function children (#631, #521) - #662

Open
trinadhkoya wants to merge 1 commit into
LegendApp:mainfrom
trinadhkoya:fix/631-function-children-arg-signature
Open

fix: preserve signature of observable function children (#631, #521)#662
trinadhkoya wants to merge 1 commit into
LegendApp:mainfrom
trinadhkoya:fix/631-function-children-arg-signature

Conversation

@trinadhkoya

@trinadhkoya trinadhkoya commented Aug 30, 2026

Copy link
Copy Markdown

Summary

Fixes #631 and #521 — both stem from the same reduction in the ObservableFunctionChildren type.

Function children stored in an observable that return a non-void value had their signature reduced to () => t:

Fix

In src/observableTypes.ts, ObservableFunctionChildren now intersects with the original function type T[K] instead of () => t, preserving the full call signature and return type:

- : Observable<t> & (() => t)
+ : Observable<t> & T[K]

This is the fix proposed by the original reporter in #631.

Tests

Added type tests in tests/types.test.ts:

  • issue #631 — asserts the argument signature is preserved (fails on the old type with Expected 0 arguments, but got 1).
  • issue #521 — asserts an async no-arg child keeps its Promise<number> return type.

Both tests fail against the previous type and pass with the fix.

Verification

  • npm run lint:check
  • npm run format:check
  • npm run typecheck ✅ (fails without the fix, confirming the new tests guard it)
  • npm run build

@trinadhkoya
trinadhkoya force-pushed the fix/631-function-children-arg-signature branch from c9feddc to b9d22c6 Compare August 30, 2026 16:32
@trinadhkoya trinadhkoya changed the title fix: preserve argument signature of observable function children (#631) fix: preserve signature of observable function children (#631, #521) Aug 30, 2026
Function children that returned a non-void value were reduced to
`() => t` in `ObservableFunctionChildren`, dropping their parameters, so
calling such a function failed to type-check with
"Expected 0 arguments, but got 1". The same reduction unwrapped the
return type of async function children with no arguments, turning
`Promise<T>` into `T`.

Use the original function type `T[K]` so the full call signature and
return type are preserved. Fix proposed by the reporter in LegendApp#631.

Closes LegendApp#631
Closes LegendApp#521
@trinadhkoya
trinadhkoya force-pushed the fix/631-function-children-arg-signature branch from b9d22c6 to 1490651 Compare August 30, 2026 16: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.

ObservableFunctionChildren strips argument signatures from non-void functions

1 participant