diff --git a/packages/kida/src/internals/types.ts b/packages/kida/src/internals/types.ts index 3afb9066..2b01d74a 100644 --- a/packages/kida/src/internals/types.ts +++ b/packages/kida/src/internals/types.ts @@ -5,7 +5,7 @@ import type { WritableSignal, ReadableSignal, Accessor, - AnyAccessor + AnyFn } from 'agera' export type { AnyFn } from 'agera' @@ -40,10 +40,13 @@ export type ToSignal = [T] extends [AnyWritableSignal] ? ReadableSignal : WritableSignal> | ToSignal> -export type ToAccessor = [T] extends [AnyAccessor] +// Both of these test any function, not just a zero-argument one: the runtime +// test behind them is `typeof value === 'function'`, so a callback is handed +// back untouched exactly like an accessor is, and the type has to say the same +export type ToAccessor = [T] extends [AnyFn] ? T - : Accessor> | Extract + : Accessor> | Extract -export type ToAccessorOrSignal = [T] extends [AnyAccessor] +export type ToAccessorOrSignal = [T] extends [AnyFn] ? T - : WritableSignal> | Extract + : WritableSignal> | Extract