language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

Falsy hint (unused var) when using svelte:component "this" prop with quoted value

Open ZerdoX-x opened this issue 3 years ago • 1 comments

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).

ZerdoX-x avatar Aug 09 '22 13:08 ZerdoX-x

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.

jasonlyu123 avatar Aug 11 '22 05:08 jasonlyu123

Thank you! Shared my feedback in that thread.

ZerdoX-x avatar Aug 12 '22 08:08 ZerdoX-x