diff --git a/force-app/lwc/signals/core.js b/force-app/lwc/signals/core.js index 80d441d..00b950b 100644 --- a/force-app/lwc/signals/core.js +++ b/force-app/lwc/signals/core.js @@ -314,11 +314,16 @@ function $resource(fn, source, options) { error: null }; } catch (error) { - _signal.value = onError(error, _value, { identifier, initialValue }) ?? { - data: null, - loading: false, - error - }; + const errorValue = onError(error, _value, { identifier, initialValue }); + if (errorValue) { + _signal.value = errorValue; + } else { + _signal.value = { + data: null, + loading: false, + error + }; + } } finally { _isInitialLoad = false; } diff --git a/src/lwc/signals/core.ts b/src/lwc/signals/core.ts index 3f56554..19357ba 100644 --- a/src/lwc/signals/core.ts +++ b/src/lwc/signals/core.ts @@ -599,10 +599,10 @@ function isSignal(anything: unknown): anything is Signal { ); } -class Binder { +class Binder { constructor( - private component: Record, - private propertyName: string + private component: Element, + private propertyName: keyof Element, ) {} to(signal: Signal) { @@ -615,8 +615,8 @@ class Binder { } } -function bind(component: Record, propertyName: string) { - return new Binder(component, propertyName); +function bind(component: T, propertyName: keyof T) { + return new Binder(component, propertyName); } export { @@ -628,3 +628,4 @@ export { bind as $bind, isSignal }; +