Replies: 4 comments 15 replies
-
Does not work, the signals in Svelte are an invisible implementation detail. let reactive = $state(0);
let reactive_trust_me = reactive; // type is the same, but this is not reactive See: |
Beta Was this translation helpful? Give feedback.
-
@brunnerh thanks a lot for your reply I know what you mean, I'm proposing to change that, and make the type system be aware of the fact that it's a signal |
Beta Was this translation helpful? Give feedback.
-
A branded type could solve this! |
Beta Was this translation helpful? Give feedback.
-
This seems to be a failure in the signal implementation—the very type of footgun that v5 was meant to solve. |
Beta Was this translation helpful? Give feedback.
-
A breaking change that hasn't receives as much publicity as I would have expected is the fact that a component behavior can greatly change depending on how props are passed to it, more specifically, to be reactive the caller has to declare the prop variable with $state
so you can't really rely on the prop being reactive, there's no way (that I know) to make sure it is reactive, and typescript knows nothing about it.
I just stumbled upon this example from deno's fresh (https://www.infoworld.com/article/3523813/intro-to-deno-fresh-a-fresh-take-on-full-stack-javascript.html?ref=dailydev)
I think it would be really helpful to let the type system know that a component is expecting a reactive variable, it would catch a lot of bugs, and it would make our code more clear al explicit.
It would also be useful because it would be more obvious that we are in fact dealing with a proxy.
In svelte 4 we had the $store syntax which made it pretty obvious that we were dealing with a reactive store.
do you think it's possible to do such a thing?
Beta Was this translation helpful? Give feedback.
All reactions