Svelte 5: No error when passing the wrong type into a bindable property
wackbyte opened this issue · 6 comments
wackbyte commented
Describe the bug
svelte-check does not error when a value of the wrong type is passed into a bindable property.
Reproduction
Test.svelte
<script lang="ts">
let {
prop = $bindable(""),
}: {
prop?: string;
} = $props();
// errors will occur here if `prop` is used incorrectly
</script>
App.svelte
<script lang="ts">
import Test from "./Test.svelte";
</script>
<Test prop=1 />
<!-- no error here! -->
Logs
No response
System Info
System:
OS: Linux 6.8 NixOS 24.05 (Uakari) 24.05 (Uakari)
CPU: (12) x64 AMD Ryzen 5 3600X 6-Core Processor
Memory: 8.48 GB / 15.56 GB
Container: Yes
Shell: 5.2.26 - /nix/store/h3bhzvz9ipglcybbcvkxvm4vg9lwvqg4-bash-5.2p26/bin/bash
Binaries:
Node: 20.12.2 - /nix/store/71r8n7ckcpvav9qwshlr12hjd5nlchds-nodejs-20.12.2/bin/node
npm: 10.5.0 - /nix/store/71r8n7ckcpvav9qwshlr12hjd5nlchds-nodejs-20.12.2/bin/npm
pnpm: 8.15.5 - /nix/store/vcm0aysl9vsas3awwqdwwrh1r074qcnd-pnpm-8.15.5/bin/pnpm
npmPackages:
svelte: 5.0.0-next.127 => 5.0.0-next.127
Using svelte-check 3.1.7.
Severity
annoyance
dummdidumm commented
Are you using the latest version of svelte-check?
wackbyte commented
Yes, I am using svelte-check 3.7.1. Is the issue not occurring on your end?
wackbyte commented
The type was any
on hover in v14.8.0 of the VS Code extension, but after just now updating to v14.8.1, it correctly shows string
. However, it (and by extension svelte-check) continues to not error with the example code.
wackbyte commented
Hm, should I have reported this in the language-tools repository?
jasonlyu123 commented
This is expected. prop=1
is equivalent to prop="1"
which is string.
wackbyte commented
Ah, looks like I forgot about unquoted attributes. Thank you!