fix: lift unsafe_state_mutation constraints for SvelteSet and SvelteMap created inside the derived #16221
+418
−19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #16211. Changes are mostly tests.
Currently mutating signals local to derived is allowed for primitives, arrays and objects, but not for sets and maps. Since the goal of derived is to be pure, mutating signals created inside it does not violate purity anyhow. This PR makes behavior consistent for sets and maps. Also covering all the other cases with tests to ensure future consistency.
Update: also applied the change to SvelteDate, SvelteURL and SvelteURLSearchParams
Tests are passing, but
pnpm lint
is crashing withError: Cannot find module ' /Code/svelte/node_modules/.pnpm/svelte-eslint-parser@0.43.0_svelte@packages+svelte/node_modules/svelte/compiler/index.js'
. Not sure what to do about it.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