Repository: sveltejs/svelte
File: packages/svelte/src/compiler/phases/3-transform/client/utils.js (JavaScript)

Code before:
				/** @type {import('estree').Expression} */ (visit(node.right))
			)
		);
	}

	const is_store = binding.kind === 'store_sub';
	const left_name = is_store ? left.name.slice(1) : left.name;

	if (
		binding.kind !== 'state' &&
		binding.kind !== 'frozen_state' &&
		binding.kind !== 'prop' &&
		binding.kind !== 'bindable_prop' &&
		binding.kind !== 'each' &&
		binding.kind !== 'legacy_reactive' &&
		!is_store
	) {
		// TODO error if it's a computed (or rest prop)? or does that already happen elsewhere?
		return fallback();
	}

	const value = get_assignment_value(node, context);

	const serialize = () => {
		if (left === node.left) {
			const initial_bindable_proxy =
				binding.initial &&
				binding.initial.type !== 'ClassDeclaration' &&
				binding.initial.type !== 'FunctionDeclaration' &&
				binding.initial.type !== 'ImportDeclaration' &&
				binding.initial.type !== 'EachBlock' &&
				should_proxy_or_freeze(binding.initial, context.state.scope);
			if (
				binding.kind === 'prop' ||
				(binding.kind === 'bindable_prop' && !initial_bindable_proxy)
			) {
				return b.call(left, value);
			} else if (is_store) {
				return b.call('$.store_set', serialize_get_binding(b.id(left_name), state), value);
			} else {
				let call;
				if (binding.kind === 'state') {
					call = b.call(
						'$.set',
						b.id(left_name),
						context.state.analysis.runes &&
							!options?.skip_proxy_and_freeze &&
							should_proxy_or_freeze(value, context.state.scope)
							? serialize_proxy_reassignment(value, left_name, state)
							: value
					);

Review comment (suggestion):
It's impossible to have a default value that is one of the things you guard against, so I think it's fine to just type cast here instead 

Code after:
				/** @type {import('estree').Expression} */ (visit(node.right))
			)
		);
	}

	const is_store = binding.kind === 'store_sub';
	const left_name = is_store ? left.name.slice(1) : left.name;

	if (
		binding.kind !== 'state' &&
		binding.kind !== 'frozen_state' &&
		binding.kind !== 'prop' &&
		binding.kind !== 'bindable_prop' &&
		binding.kind !== 'each' &&
		binding.kind !== 'legacy_reactive' &&
		!is_store
	) {
		// TODO error if it's a computed (or rest prop)? or does that already happen elsewhere?
		return fallback();
	}

	const value = get_assignment_value(node, context);

	const serialize = () => {
		if (left === node.left) {
			const is_initial_proxy =
				binding.initial !== null &&
				should_proxy_or_freeze(
					/**@type {import("estree").Expression}*/ (binding.initial),
					context.state.scope
				);
			if ((binding.kind === 'prop' || binding.kind === 'bindable_prop') && !is_initial_proxy) {
				return b.call(left, value);
			} else if (is_store) {
				return b.call('$.store_set', serialize_get_binding(b.id(left_name), state), value);
			} else {
				let call;
				if (binding.kind === 'state') {
					call = b.call(
						'$.set',
						b.id(left_name),
						context.state.analysis.runes &&
							!options?.skip_proxy_and_freeze &&
							should_proxy_or_freeze(value, context.state.scope)
							? serialize_proxy_reassignment(value, left_name, state)
							: value
					);
				} else if (binding.kind === 'frozen_state') {
					call = b.call(
						'$.set',
						b.id(left_name),