{"record":{"id":"89a21198f71f7101","repo":"sveltejs/svelte","slug":"props-rest-readonly","errorCode":"props_rest_readonly","errorMessage":"props_rest_readonly\nRest element properties of `$props()` such as `${property}` are readonly\nhttps://svelte.dev/e/props_rest_readonly","messagePattern":"props_rest_readonly\nRest element properties of `\\$props\\(\\)` such as `(.+?)` are readonly\nhttps://svelte\\.dev/e/props_rest_readonly","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/svelte/src/internal/client/errors.js","lineNumber":411,"sourceCode":"\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/props_invalid_value`);\n\t}\n}\n\n/**\n * Rest element properties of `$props()` such as `%property%` are readonly\n * @param {string} property\n * @returns {never}\n */\nexport function props_rest_readonly(property) {\n\tif (DEV) {\n\t\tconst error = new Error(`props_rest_readonly\\nRest element properties of \\`$props()\\` such as \\`${property}\\` are readonly\\nhttps://svelte.dev/e/props_rest_readonly`);\n\n\t\terror.name = 'Svelte error';\n\n\t\tthrow error;\n\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/props_rest_readonly`);\n\t}\n}\n\n/**\n * The `%rune%` rune is only available inside `.svelte` and `.svelte.js/ts` files\n * @param {string} rune\n * @returns {never}\n */\nexport function rune_outside_svelte(rune) {\n\tif (DEV) {\n\t\tconst error = new Error(`rune_outside_svelte\\nThe \\`${rune}\\` rune is only available inside \\`.svelte\\` and \\`.svelte.js/ts\\` files\\nhttps://svelte.dev/e/rune_outside_svelte`);\n\n\t\terror.name = 'Svelte error';\n\n\t\tthrow error;\n\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/rune_outside_svelte`);\n\t}","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/sveltejs/svelte/blob/20b341f10048cf1016a2028ac7eee5595cfef6a5/packages/svelte/src/internal/client/errors.js#L393-L429","documentation":"Thrown at reactivity/props.js:62 (DEV only) when code attempts to set a property on a rest-props object (the `...rest` from `const { a, ...rest } = $props()`). Rest props are a read-only proxy over the parent's prop bag; writing to them would not propagate back to the parent and would break reactivity, so Svelte blocks it in development.","triggerScenarios":"Destructuring rest props and then assigning: `const { x, ...rest } = $props(); rest.y = 1;`. The Proxy `set` trap at props.js:59-63 calls the error in DEV.","commonSituations":"Trying to mutate extra props before forwarding them; refactoring from Svelte 4 $$props mutation; setting a computed value onto rest for convenience.","solutions":["Create a new object with the desired shape instead of mutating rest: `const forwarded = { ...rest, y: 1 }`.","If you need mutable local state derived from props, copy values into a $state variable.","Spread rest into a child component without modifying it."],"exampleFix":"// before\nconst { x, ...rest } = $props();\nrest.extra = computed; // throws in DEV\n\n// after\nconst { x, ...rest } = $props();\nconst forwarded = { ...rest, extra: computed };","handlingStrategy":"validation","validationCode":"// Never assign to rest-props properties. Spread instead.\n// const { a, ...rest } = $props();\n// const next = { ...rest, b: 1 };","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat rest props as read-only.","Build a new object with spread when you need to add or override keys.","Copy needed prop values into $state if you need mutable local copies."],"tags":["svelte","runes","props","readonly","dev-only"],"backgroundTag":null,"analyzedSha":"20b341f10048cf1016a2028ac7eee5595cfef6a5","analyzedAt":"2026-08-12T23:37:30.399Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}