You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I work on a small form library based on signals and discovered an annoying issue with computeds
import{Signal}from'signal-polyfill';interfaceBroader{strProp: string;}interfaceNarrowerextendsBroader{numProp: number;}conststate=newSignal.State<Narrower>({strProp: '',numProp: 33,});// not assignable, but should be, right?constderived: Signal.Computed<Broader>=newSignal.Computed(()=>state.get());
It impairs ability to consume computed signals, for example:
interfaceFormState<T>{value: T;errors: unknown;}classFormControl<T>{
#state: Signal.State<FormState<T>>;readonly$state=newSignal.Computed(()=>this.#state.get());constructor(intiValue: T){this.#state =newSignal.State<FormState<T>>({value: intiValue,errors: null,});}}constnumControl=newFormControl(0);functionvalueConsumer(onlyValueState: Signal.Computed<{value: number}>){console.log(onlyValueState.get().value);}// errors, Argument of type 'Computed<FormState<number>>' is not assignable to parameter of type 'Computed<{ value: number; }>'valueConsumer(numControl.$state);
I work on a small form library based on signals and discovered an annoying issue with computeds
It impairs ability to consume computed signals, for example:
repro: https://stackblitz.com/edit/vitejs-vite-jueqfh?file=src%2Fmain.ts
The text was updated successfully, but these errors were encountered: