-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reactivity missing for a $derived member function call in Tagged Template syntax without object name #12687
Comments
One should not need to declare functions as This should also just work but does not right now: let count = $state(0);
function showCount(s) {
return s ' ' count;
} {showCount`...`} |
@brunnerh Thanks for your helpful comment. |
When deciding if applying a template_effect the compiler is probably just looking for |
Describe the bug
First, remember that a function like
showCount(label: string)
can be called with the Tagged Template syntax of javascript asIf such a function is declared with
$derived
ascalling
showCount
from a.svelte
file such as{showCount`Count:`}
becomes reactive and is re-evaluated whencount
is updated.When
count
andshowCount
are members of a class object, it is also reactive as expected, so that{obj.showCount`Count:`}
is re-evaluated whenobj.count
is updated.An issue is observed when
obj.showCount
is stored in a variable.In this case,
{showCount('Count:')}
is still reactive but{showCount`Count:`}
is no more.Svelte 5 compiler fails to apply
$.template_effect
to $derive member function calls in Tagged Template syntax without object name.Reproduction
Here is a demonstration code. Try it online at svelte-5-preview.vercel.app.
After clicking the button four times, the result was as follows:
Only the member function call in the tagged template syntax without object name is missing reactivity.
Logs
No response
System Info
The text was updated successfully, but these errors were encountered: