-
-
Notifications
You must be signed in to change notification settings - Fork 223
Closed
sveltejs/svelte
#16142Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
I followed the documentation (https://svelte.dev/docs/svelte/bind#Function-bindings) to write code using bind:clientWidth, but I encountered an error:
Object literal may only specify known properties, and '"bind:clientWidth"' does not exist in type 'HTMLProps<"div", HTMLAttributes<any>>'.ts(2353)
However, if I ignore the error reported by VSCode, the page works as expected.
Additionally, I noticed that the following code works fine:
<div bind:clientWidth={w}>content</div>
But when I use it like this, it doesn't work:
<div bind:clientWidth={null, (v) => w=v}>content</div>
Version:
- VSCode: 1.98.2 (Universal)
- svelte.svelte-vscode: 109.5.3 (2025-03-06, 23:40:48)
Reproduction
<script lang="ts"> let w=$state(0); </script> w=v}>content
Logs
System Info
System:
OS: macOS 14.0
CPU: (10) arm64 Apple M1 Pro
Memory: 87.77 MB / 16.00 GB
Shell: 5.2.32 - /opt/homebrew/bin/bash
Binaries:
Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
npm: 11.0.0 - ~/.nvm/versions/node/v20.17.0/bin/npm
pnpm: 9.15.1 - ~/.nvm/versions/node/v20.17.0/bin/pnpm
Browsers:
Chrome: 135.0.7049.42
Safari: 17.0
npmPackages:
svelte: ^5.0.0 => 5.25.3Severity
annoyance
bed42, truongvan and hpeebles
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working