Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prop bind produces 'variable is declared but its value is never read' #2268

Open
minht11 opened this issue Jan 23, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@minht11
Copy link

minht11 commented Jan 23, 2024

Describe the bug

Use bind shorthand with the prop, get error 'offsetWidth' is declared but its value is never read.ts(6133)

Reproduction

Run code below in VS code.

<script lang="ts">
	let {
		offsetWidth,
	} = $props<{
		offsetWidth?: number
	}>()
</script>

<div
	bind:offsetWidth
/>

Expected behaviour

No error.

System Info

  • OS: [e.g. Macos]
  • IDE: [e.g. VSCode]

Which package is the issue about?

svelte-language-server

Additional Information, eg. Screenshots

image
@minht11 minht11 added the bug Something isn't working label Jan 23, 2024
@dummdidumm
Copy link
Member

Under the hood the binding is transpiled to something like offsetWidth = div.offsetWidth, and so for TS offsetWidth is only reassigned but never read. But if this thing is used as a binding then it's obviously ok to never read it inside, because the outside will read it. The fix is to add a dummy-read in generated code somewhere, but I'm not sure yet how where to add this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants