Repository: sveltejs/svelte
File: packages/svelte/src/compiler/migrate/index.js (JavaScript)

Code before:
					// 	}
					// }
				}

				const binding = /** @type {Compiler.Binding} */ (state.scope.get(declarator.id.name));

				if (
					state.analysis.uses_props &&
					(declarator.init || binding.mutated || binding.reassigned)
				) {
					throw new Error(
						'$$props is used together with named props in a way that cannot be automatically migrated.'
					);
				}

				state.props.push({
					local: declarator.id.name,
					exported: binding.prop_alias ? binding.prop_alias : declarator.id.name,
					init: declarator.init
						? state.str.original.substring(
								/** @type {number} */ (declarator.init.start),
								/** @type {number} */ (declarator.init.end)
							)
						: '',
					optional: !!declarator.init,
					bindable: binding.mutated || binding.reassigned,
					...extract_type_and_comment(declarator, state.str, path)
				});
				state.props_insertion_point = /** @type {number} */ (declarator.end);
				state.str.update(
					/** @type {number} */ (declarator.start),
					/** @type {number} */ (declarator.end),
					''
				);

				continue;
			}

			// state
			if (declarator.init) {
				state.str.prependLeft(/** @type {number} */ (declarator.init.start), '$state(');
				state.str.appendRight(/** @type {number} */ (declarator.init.end), ')');
			} else {
				state.str.prependLeft(
					/** @type {number} */ (declarator.id.typeAnnotation?.end ?? declarator.id.end),
					' = $state()'
				);
			}
		}

		if (nr_of_props === node.declarations.length) {

Review comment (suggestion):
ditto. if there's a case where `binding.updated !== (binding.mutated || binding.reassigned)` then that needs to be fixed

Code after:
					// 	}
					// }
				}

				const binding = /** @type {Compiler.Binding} */ (state.scope.get(declarator.id.name));

				if (state.analysis.uses_props && (declarator.init || binding.updated)) {
					throw new Error(
						'$$props is used together with named props in a way that cannot be automatically migrated.'
					);
				}

				state.props.push({
					local: declarator.id.name,
					exported: binding.prop_alias ? binding.prop_alias : declarator.id.name,
					init: declarator.init
						? state.str.original.substring(
								/** @type {number} */ (declarator.init.start),
								/** @type {number} */ (declarator.init.end)
							)
						: '',
					optional: !!declarator.init,
					bindable: binding.updated,
					...extract_type_and_comment(declarator, state.str, path)
				});
				state.props_insertion_point = /** @type {number} */ (declarator.end);
				state.str.update(
					/** @type {number} */ (declarator.start),
					/** @type {number} */ (declarator.end),
					''
				);

				continue;
			}

			// state
			if (declarator.init) {
				state.str.prependLeft(/** @type {number} */ (declarator.init.start), '$state(');
				state.str.appendRight(/** @type {number} */ (declarator.init.end), ')');
			} else {
				state.str.prependLeft(
					/** @type {number} */ (declarator.id.typeAnnotation?.end ?? declarator.id.end),
					' = $state()'
				);
			}
		}

		if (nr_of_props === node.declarations.length) {
			let start = /** @type {number} */ (node.start);
			let end = /** @type {number} */ (node.end);