Closed as not planned
Description
Describe the bug
At the moment (Svelte 5.0.0-next.162) both:
const { value } = $props()
and
let { value } = $props()
work without issue or warning.
Allowing const
here is confusing as the meaning in Javascript is that the value is never re-assigned, but in case of $props and $derived the value will be reassigned. It's not something we do, but something the Svelte reactivity system does.
Although I think let
is the correct declaration type, const has the benefit of blocking assignments Cannot assign to constant
and we shouldn't reassign most props or derived values.
For derived values the compiler already protects us against that Cannot assign to derived state
🎉
( It would be nice if the compiler also protects us against assigning against assigning values to nonbindable props.)
Reproduction
Logs
No response
System Info
System:
OS: macOS 14.5
CPU: (12) arm64 Apple M3 Pro
Memory: 112.45 MB / 36.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 21.6.2 - /opt/homebrew/bin/node
Yarn: 1.22.21 - ~/Library/pnpm/yarn
npm: 10.8.1 - /opt/homebrew/bin/npm
pnpm: 9.4.0 - ~/Library/pnpm/pnpm
Browsers:
Brave Browser: 125.1.66.110
Chrome: 126.0.6478.63
Safari: 17.5
npmPackages:
svelte: 5.0.0-next.162 => 5.0.0-next.162
Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels