sveltejs/svelte · error · Error

props_rest_readonly

props_rest_readonly

Error message

props_rest_readonly
Rest element properties of `$props()` such as `${property}` are readonly
https://svelte.dev/e/props_rest_readonly

What it means

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.

Source

Thrown at packages/svelte/src/internal/client/errors.js:411

	} else {
		throw new Error(`https://svelte.dev/e/props_invalid_value`);
	}
}

/**
 * Rest element properties of `$props()` such as `%property%` are readonly
 * @param {string} property
 * @returns {never}
 */
export function props_rest_readonly(property) {
	if (DEV) {
		const error = new Error(`props_rest_readonly\nRest element properties of \`$props()\` such as \`${property}\` are readonly\nhttps://svelte.dev/e/props_rest_readonly`);

		error.name = 'Svelte error';

		throw error;
	} else {
		throw new Error(`https://svelte.dev/e/props_rest_readonly`);
	}
}

/**
 * The `%rune%` rune is only available inside `.svelte` and `.svelte.js/ts` files
 * @param {string} rune
 * @returns {never}
 */
export function rune_outside_svelte(rune) {
	if (DEV) {
		const 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`);

		error.name = 'Svelte error';

		throw error;
	} else {
		throw new Error(`https://svelte.dev/e/rune_outside_svelte`);
	}

View on GitHub (pinned to 20b341f100)

Solutions

  1. Create a new object with the desired shape instead of mutating rest: `const forwarded = { ...rest, y: 1 }`.
  2. If you need mutable local state derived from props, copy values into a $state variable.
  3. Spread rest into a child component without modifying it.

Example fix

// before
const { x, ...rest } = $props();
rest.extra = computed; // throws in DEV

// after
const { x, ...rest } = $props();
const forwarded = { ...rest, extra: computed };
Defensive patterns

Strategy: validation

Validate before calling

// Never assign to rest-props properties. Spread instead.
// const { a, ...rest } = $props();
// const next = { ...rest, b: 1 };

Prevention

When it happens

Trigger: 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.

Common situations: Trying to mutate extra props before forwarding them; refactoring from Svelte 4 $$props mutation; setting a computed value onto rest for convenience.

Related errors


AI-assisted analysis of sveltejs/svelte@20b341f100 (2026-08-12). Data as JSON: /api/errors/89a21198f71f7101. Report an issue: GitHub.