language-tools
language-tools copied to clipboard
Falsy hint (unused var) when using svelte:component "this" prop with quoted value
repro: https://git.sr.ht/~zerdox/sveltejs-language-tools-1580
search keywords: is declared but its value is never read. ts(6133) is declared but its value is never read. (js) unused variable svelte-check
Here is some code for you to preview the reproduction:
This one works fine:
{#await import('./Comp1.svelte') then component}
<svelte:component this={component.default} />
{/await}
This one gives falsy hint:
{#await import('./Comp1.svelte') then component}
<svelte:component this="{component.default}" />
{/await}
You can see the only difference here is quotes. And no, you don't need to async import in order to reproduce this issue. Look repro for examples.
This falsy hint appears in both svelte-check and vscode (with svelte.svelte-vscode extension).
This won't happen in the new transformation, which would be default soon. Given it's an edge case and it doesn't affect type-check I am hesitant to fix it now. See this issue for info on how to turn it on now. And we'll be happy to see if you have any feedback about it.
Thank you! Shared my feedback in that thread.