Skip to content

Signal is exposed when creating $derived value accessor #10293

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

Closed
Thiagolino8 opened this issue Jan 25, 2024 · 4 comments · Fixed by #10430
Closed

Signal is exposed when creating $derived value accessor #10293

Thiagolino8 opened this issue Jan 25, 2024 · 4 comments · Fixed by #10430
Milestone

Comments

@Thiagolino8
Copy link

Thiagolino8 commented Jan 25, 2024

Describe the bug

$.get is not used when creating $derived value accessor, which ends up exposing the signal

Reproduction

repl

Logs

No response

System Info

Svelte v5.0.0-next.38

Severity

annoyance

@trueadm trueadm assigned trueadm and unassigned trueadm Jan 30, 2024
@dummdidumm dummdidumm added this to the 5.0 milestone Feb 6, 2024
@dummdidumm
Copy link
Member

What's the use case? I think exporting things from $derived() should be a compiler error.

@dummdidumm dummdidumm added the awaiting submitter needs a reproduction, or clarification label Feb 6, 2024
@Thiagolino8
Copy link
Author

The use would be the same as for every accessor, making the state visible to the parent component
I can't see a good reason for $derived to be the exception to this functionality

@dummdidumm
Copy link
Member

It would be confusing to explain why you can export $derived like that from a component and it behaves differently compared to an export from a module. The "workaround" is to just export a function which returns the current value, which also better conveis the "this can change" notion -> this code should be a compiler error.

@dummdidumm dummdidumm removed the awaiting submitter needs a reproduction, or clarification label Feb 8, 2024
dummdidumm added a commit that referenced this issue Feb 8, 2024
disallow exporting props, derived and reassigned state from within components
closes #10310, closes #10311, closes #10293
@Rich-Harris
Copy link
Member

note that we reverted this change in #10523, this will now work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants