-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
feat: allow $state
in return statements
#15589
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: e13c7d9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
I'm not sure if this should also apply to implicit returns in arrow functions, does anyone have any input on that? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be good to have a test, which would also help illuminate what is being supported
@@ -0,0 +1,5 @@ | |||
--- | |||
'svelte': patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe new features are normally considered a minor
release
'svelte': patch | |
'svelte': minor |
I'll add the test in a bit. This PR allows you to return a function fn() {
//...
return $state(obj);
} In this example, |
This allows
$state
calls to be returned from a function, returning a proxy (if the argument can be proxied). This has been mentioned a few times, but I can't find the issues. I don't know if we should warn on arguments that aren't proxiable, I'm leaning towards 'no' since that would probably be unnecessary.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.packages/svelte/src
, add a changeset (npx changeset
).Tests and linting
pnpm test
and lint the project withpnpm lint