Skip to content

Commit 2090823

Browse files
committed
drive-by tidy up
1 parent 43a60fd commit 2090823

File tree

1 file changed

+21
-21
lines changed
  • packages/svelte/src/compiler/migrate

1 file changed

+21
-21
lines changed

packages/svelte/src/compiler/migrate/index.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,6 @@ const instance_script = {
949949
const ids = extract_identifiers(left);
950950
const [, expression_ids] = extract_all_identifiers_from_expression(right);
951951
const bindings = ids.map((id) => /** @type {Binding} */ (state.scope.get(id.name)));
952-
const reassigned_bindings = bindings.filter((b) => b.reassigned);
953952

954953
if (bindings.every((b) => b.kind === 'legacy_reactive')) {
955954
if (
@@ -982,28 +981,29 @@ const instance_script = {
982981
}
983982

984983
return;
985-
} else {
986-
for (const binding of reassigned_bindings) {
987-
if (binding && (ids.includes(binding.node) || expression_ids.length === 0)) {
988-
check_rune_binding('state');
989-
const init =
990-
binding.kind === 'state'
991-
? ' = $state()'
992-
: expression_ids.length === 0
993-
? ` = $state(${state.str.original.substring(/** @type {number} */ (right.start), right.end)})`
994-
: '';
995-
// implicitly-declared variable which we need to make explicit
996-
state.str.prependLeft(
997-
/** @type {number} */ (node.start),
998-
`let ${binding.node.name}${init};\n${state.indent}`
999-
);
1000-
}
1001-
}
1002-
if (expression_ids.length === 0 && !bindings.some((b) => b.kind === 'store_sub')) {
1003-
state.str.remove(/** @type {number} */ (node.start), /** @type {number} */ (node.end));
1004-
return;
984+
}
985+
986+
for (const binding of bindings) {
987+
if (binding.reassigned && (ids.includes(binding.node) || expression_ids.length === 0)) {
988+
check_rune_binding('state');
989+
const init =
990+
binding.kind === 'state'
991+
? ' = $state()'
992+
: expression_ids.length === 0
993+
? ` = $state(${state.str.original.substring(/** @type {number} */ (right.start), right.end)})`
994+
: '';
995+
// implicitly-declared variable which we need to make explicit
996+
state.str.prependLeft(
997+
/** @type {number} */ (node.start),
998+
`let ${binding.node.name}${init};\n${state.indent}`
999+
);
10051000
}
10061001
}
1002+
1003+
if (expression_ids.length === 0 && bindings.every((b) => b.kind !== 'store_sub')) {
1004+
state.str.remove(/** @type {number} */ (node.start), /** @type {number} */ (node.end));
1005+
return;
1006+
}
10071007
}
10081008
}
10091009

0 commit comments

Comments
 (0)