tomblachut / svelte-intellij

Svelte components in WebStorm and friends
MIT License
485 stars 38 forks source link

$: Reactive statement may inject undeclared variable - shown as error in plugin #112

Closed Treverix closed 4 years ago

Treverix commented 4 years ago

From the svelte API:

If a statement consists entirely of an assignment to an undeclared variable, Svelte will inject a let declaration on your behalf.

So basically, this is valid code in svelte - but shown as an error in the IDE

<script>
$: foo = "bar";
</script>

svelte will inject a let foo so foo shouldn't be displayed as an unresolved variable here.

Extended example - both foo and bar shouldn't be shown in error:

<script>
$: foo = "bar";
$: bar = foo;
</script>
tomblachut commented 4 years ago

Yes, this is very tricky to implement.

Closing in favor of #7