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

Code before:
				continue;
			}

			// state
			if (declarator.init) {
				let { start, end } = /** @type {{ start: number, end: number }} */ (declarator.init);

				if (declarator.init.type === 'SequenceExpression') {
					while (state.str.original[start] !== '(') start -= 1;
					while (state.str.original[end - 1] !== ')') end += 1;
				}

				state.str.prependLeft(start, '$state(');
				state.str.appendRight(end, ')');
			} else {
				/**
				 * @type {AssignmentExpression | undefined}
				 */
				let assignment_in_labeled;
				/**
				 * @type {LabeledStatement | undefined}
				 */
				let labeled_statement;

				const possible_derived = bindings.every((binding) =>
					binding.references.every((reference) => {
						const declaration_idx = reference.path.find((el) => el.type === 'VariableDeclaration');
						const assignment_idx = reference.path.find((el) => el.type === 'AssignmentExpression');
						const update_idx = reference.path.find((el) => el.type === 'UpdateExpression');
						const labeled_idx = reference.path.find(
							(el) => el.type === 'LabeledStatement' && el.label.name === '$'
						);

						if (assignment_idx && labeled_idx) {
							if (assignment_in_labeled) return false;
							assignment_in_labeled = /** @type {AssignmentExpression} */ (assignment_idx);
							labeled_statement = /** @type {LabeledStatement} */ (labeled_idx);
						}

						return (
							!update_idx &&
							(declaration_idx ||
								(labeled_idx && assignment_idx) ||
								(!labeled_idx && !assignment_idx))
						);
					})
				);

				const labeled_has_single_assignment =
					labeled_statement?.body.type === 'BlockStatement' &&
					labeled_statement.body.body.length === 1;

Review comment (suggestion):
```suggestion
				// Analyze declaration bindings to see if they're exclusively updated within a single reactive statement
				const possible_derived = bindings.every((binding) =>
```

Code after:
				continue;
			}

			// state
			if (declarator.init) {
				let { start, end } = /** @type {{ start: number, end: number }} */ (declarator.init);

				if (declarator.init.type === 'SequenceExpression') {
					while (state.str.original[start] !== '(') start -= 1;
					while (state.str.original[end - 1] !== ')') end += 1;
				}

				state.str.prependLeft(start, '$state(');
				state.str.appendRight(end, ')');
			} else {
				/**
				 * @type {AssignmentExpression | undefined}
				 */
				let assignment_in_labeled;
				/**
				 * @type {LabeledStatement | undefined}
				 */
				let labeled_statement;

				// Analyze declaration bindings to see if they're exclusively updated within a single reactive statement
				const possible_derived = bindings.every((binding) =>
					binding.references.every((reference) => {
						const declaration = reference.path.find((el) => el.type === 'VariableDeclaration');
						const assignment = reference.path.find((el) => el.type === 'AssignmentExpression');
						const update = reference.path.find((el) => el.type === 'UpdateExpression');
						const labeled = reference.path.find(
							(el) => el.type === 'LabeledStatement' && el.label.name === '$'
						);

						if (assignment && labeled) {
							if (assignment_in_labeled) return false;
							assignment_in_labeled = /** @type {AssignmentExpression} */ (assignment);
							labeled_statement = /** @type {LabeledStatement} */ (labeled);
						}

						return !update && (declaration || (labeled && assignment) || (!labeled && !assignment));
					})
				);

				const labeled_has_single_assignment =
					labeled_statement?.body.type === 'BlockStatement' &&
					labeled_statement.body.body.length === 1;

				const is_expression_assignment =
					labeled_statement?.body.type === 'ExpressionStatement' &&
					labeled_statement.body.expression.type === 'AssignmentExpression';