feat: add warning for non-updated bindable#17600
Conversation
🦋 Changeset detectedLatest commit: 8dea7d1 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 |
|
Ocean-OS
left a comment
There was a problem hiding this comment.
The code seems good to me, but I'm questioning whether the mutation part should be removed, since I have a feeling a decent amount of components indirectly (at least to the compiler) mutate bindable props, e.g.
<script>
let { prop = $bindable() } = $props();
function_that_mutates_prop(prop);
</script>which would lead to a false positive.
|
Mmm unless we count "passed to a function" as updated and we don't warn in that case. |
|
True, but that still would count something like let foo = { prop };
mutate(foo);as a non-mutated prop. |
|
Yeah but i think it's fine in this case...you can always update the function to actually mutate and then the warning would not make sense so better not fire "it there is the possibility". I feel like not including mutation would be worse than this no? |
|
I started out thinking 'screw the edge cases' but there's actually quite a lot of them. If the problem is 'LLMs are dumb' then it seems like telling them 'don't make props bindable unless they're reassigned' would be better. Unless we choose the lesser of two weevils:
Part of me wonders if we should just give up our quixotic attempt to prevent components from mutating stuff they don't own (i.e. get rid of the |
that indeed could be the best / most pragmatic solution |
Closes #17589
I wonder if this should actually be considered a breaking change...it's just a warning but what if someone CI depends on no warnings to pass?
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 testand lint the project withpnpm lint