You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#5847 added a warning when module variables are used reactively in non-module script.
This warning is triggered even if the variable is const. (And used reactively together with non-const variables, presumably!)
Reproduction
<scriptcontext="module">
exportconstdoFoos= (a, b, c) => [a, b, c];exportconstfoo=123;
</script>
<script>
exportlet bar;$: foobar =doFoos(foo, bar, null);
</script>
Logs
(!) Plugin svelte: "doFoos" is declared in a module script and will not be reactive
(!) Plugin svelte: "foo" is declared in a module script and will not be reactive
This generated a warning:
<script context="module">
export const foo = 123;
</script>
<script>
$: console.log(foo);
</script>
while this did not:
<script>
const foo = 123;
$: console.log(foo);
</script>
We don't need a warning to tell us that we will not be reactive to a
variable that isn't going to change anyway; regardless of whether or not
it's in a module.
(Maybe there should be a 'no reactive variable used' warning, but this
also happens in cases where other mutable variables are used; such as a
shared const formatter function, formatting a prop.)
OJFord
changed the title
[const] is declared in a module script and will not be reactive
{some const} is declared in a module script and will not be reactive
Aug 1, 2021
Describe the bug
#5847 added a warning when module variables are used reactively in non-module script.
This warning is triggered even if the variable is
const
. (And used reactively together with non-const variables, presumably!)Reproduction
Logs
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: