REFERENCE / CORE API

isSignal()

True for values created by signal() or computed(), false for everything else. A type guard in TypeScript.

Signature

TS
isSignal(v: unknown): v is Signal | Computed

Parameters

PARAMETERTYPEDESCRIPTION
v unknown Anything.

Returns

true when v is a signal or a computed. It narrows the type, so v.value type-checks inside the branch.

When you need it

Mostly in components that take props which may or may not be reactive — the one place where "is this a value or a signal?" is a real question. Templates never need it: a hole already does the right thing with a constant, a signal or a function.

JS
isSignal(signal(0));                  // true
isSignal(computed(() => 1));          // true
isSignal(0);                          // false
isSignal(() => count.value);          // false — a function hole is not a signal

// a component that accepts either a plain value or a reactive one
const Price = (amount) => html`<b>${isSignal(amount) ? () => fmt(amount.value) : fmt(amount)}</b>`;

See also