Describe the bug
If a derived signal/store/optimistic/optimisticStore has never been initialized when its setter is called the setter callback gets provided with a uninitialized prev/draft either undefined for the signal case or the seed value for the store case.
Your Example Website or App
https://stackblitz.com/edit/solidjs-templates-kkcngwa1?file=src%2FApp.tsx
Steps to Reproduce the Bug or Issue
- Open repro
- Click button
- See in console that each setter logged that they received a value that doesn't correspond to the type
Expected behavior
I honestly don't know. The alternatives are:
- Throw an error
- Update the type to reflect the reality for derived types
- Ignore the set never calling the callback
- Queue the set calling the callback once there is a value
This case should be reasonably rare but also not just hypothetical so the solution needs to way what is least bad here. Do we force everyone to handle a undefined even when the derived signal is sync and can't possibly be in this state or do we try to retain the type but introduce some possibly unintuitive behavior for what happens when it is called in this state?
My preferred solution is probably 4 however both 3 and 4 require changing the contract for the setter to no longer return the updated value as that obviously can't be done if the setter callback hasn't been called yet.
Screenshots or Videos
No response
Platform
- OS: Windows
- Browser: Firefox
Additional context
No response
Describe the bug
If a derived signal/store/optimistic/optimisticStore has never been initialized when its setter is called the setter callback gets provided with a uninitialized prev/draft either undefined for the signal case or the seed value for the store case.
Your Example Website or App
https://stackblitz.com/edit/solidjs-templates-kkcngwa1?file=src%2FApp.tsx
Steps to Reproduce the Bug or Issue
Expected behavior
I honestly don't know. The alternatives are:
This case should be reasonably rare but also not just hypothetical so the solution needs to way what is least bad here. Do we force everyone to handle a undefined even when the derived signal is sync and can't possibly be in this state or do we try to retain the type but introduce some possibly unintuitive behavior for what happens when it is called in this state?
My preferred solution is probably 4 however both 3 and 4 require changing the contract for the setter to no longer return the updated value as that obviously can't be done if the setter callback hasn't been called yet.
Screenshots or Videos
No response
Platform
Additional context
No response