diff --git a/.changeset/large-turkeys-deny.md b/.changeset/large-turkeys-deny.md new file mode 100644 index 0000000000..6dcd227f7f --- /dev/null +++ b/.changeset/large-turkeys-deny.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: improve readonly prop messaging diff --git a/packages/svelte/src/internal/client/proxy/readonly.js b/packages/svelte/src/internal/client/proxy/readonly.js index 3fce783397..abc2163d97 100644 --- a/packages/svelte/src/internal/client/proxy/readonly.js +++ b/packages/svelte/src/internal/client/proxy/readonly.js @@ -42,7 +42,7 @@ export function readonly(value) { */ const readonly_error = (_, prop) => { throw new Error( - `Non-bound props cannot be mutated — use \`bind:={...}\` to make \`${prop}\` settable. Fallback values can never be mutated.` + `Non-bound props cannot be mutated — to make the \`${prop}\` settable, ensure the object it is used within is bound as a prop \`bind:={...}\`. Fallback values can never be mutated.` ); }; diff --git a/packages/svelte/tests/runtime-runes/samples/proxy-prop-default-readonly/_config.js b/packages/svelte/tests/runtime-runes/samples/proxy-prop-default-readonly/_config.js index 352d874648..d78db389d7 100644 --- a/packages/svelte/tests/runtime-runes/samples/proxy-prop-default-readonly/_config.js +++ b/packages/svelte/tests/runtime-runes/samples/proxy-prop-default-readonly/_config.js @@ -15,5 +15,5 @@ export default test({ }, runtime_error: - 'Non-bound props cannot be mutated — use `bind:={...}` to make `count` settable. Fallback values can never be mutated.' + 'Non-bound props cannot be mutated — to make the `count` settable, ensure the object it is used within is bound as a prop `bind:={...}`. Fallback values can never be mutated.' }); diff --git a/packages/svelte/tests/runtime-runes/samples/proxy-prop-readonly/_config.js b/packages/svelte/tests/runtime-runes/samples/proxy-prop-readonly/_config.js index 352d874648..d78db389d7 100644 --- a/packages/svelte/tests/runtime-runes/samples/proxy-prop-readonly/_config.js +++ b/packages/svelte/tests/runtime-runes/samples/proxy-prop-readonly/_config.js @@ -15,5 +15,5 @@ export default test({ }, runtime_error: - 'Non-bound props cannot be mutated — use `bind:={...}` to make `count` settable. Fallback values can never be mutated.' + 'Non-bound props cannot be mutated — to make the `count` settable, ensure the object it is used within is bound as a prop `bind:={...}`. Fallback values can never be mutated.' });