sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
78.21k stars 4.09k forks source link

Warning in VScode for `svelte(unused-export-let)` when the prop is passed via `<svelte:component>` #8174

Open laztheripper opened 1 year ago

laztheripper commented 1 year ago

Describe the bug

I have a filtered array of components to display, so I use <svelte:component {id} this={tab} /> in the parent.

In the child components I have export let id = ""; However, vscode is telling me:

Component has unused export property 'id'. If it is for external reference only, please consider using `export const id`svelte(unused-export-let)

I am unsure where the warning is coming from, but the code does compile and the value can be read correctly on the front-end. The only solution I've found to suppress the warning in my vscode editor is to add <!-- svelte-ignore unused-export-let --> to the top of every affected child component.

Thank you.

Reproduction

Parent

<script>
     import tab from './tab.svelte';
</script>

<svelte:component id='myid' this={tab} />

Child

<script>
     export let id = '';
</script>

Logs

No response

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 AMD Ryzen 7 2700X Eight-Core Processor
    Memory: 17.17 GB / 31.95 GB
  Binaries:
    Node: 19.3.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.21.1 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.2.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 108.0.5359.125
    Edge: Spartan (44.19041.1266.0), Chromium (108.0.1462.76)
    Internet Explorer: 11.0.19041.1566

Severity

annoyance

phamduylong commented 1 year ago

Can you give some information on what plugins are you having for svelte on VS Code? This seems to be some kind of warning by the plugins more than Svelte itself

jasonlyu123 commented 1 year ago

From your reproduction, you indeed didn't use the id props. So the warning should be correct. Are you missing something from the reproduction? Or what were you expected it to be?

sandersrd33 commented 1 year ago

You probably want to put this in your vscode workspace settings: "svelte.plugin.svelte.compilerWarnings": { "unused-export-let": "ignore", }