News for hackers. Stuff that matters.
Re:Svelte 5: Runes by Phillippe on Wednesday September 20, 2023 @01:14PM (#37586854)
Maybe reuse the $:{} here, tho that would probably be really confusing for svelte 4 developers lol

$:{ let name = 'world'; };

vs

let name = $state('world');

$: is valid javascript right? So that should also work in .js/.ts files I assume

Re:Svelte 5: Runes by codelikeawolf on Thursday September 21, 2023 @03:59AM (#37594546)
I think the reason they didn't opt for this approach is that putting stuff in a {} block creates its own scope, so any variables declared within that block are inaccessible from outside said scope.

The $: label syntax is valid JavaScript, but allowing scoped variables to be accessible outside of scope is very invalid JavaScript.