Skip to content

Commit c793cf3

Browse files
committed
simplify
1 parent e7fa79a commit c793cf3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,18 @@ export function VariableDeclaration(node, context) {
127127
* @param {Expression} [options]
128128
*/
129129
const create_state_declarator = (id, value, options) => {
130-
const binding = /** @type {import('#compiler').Binding} */ (
131-
context.state.scope.get(id.name)
132-
);
130+
const binding = /** @type {Binding} */ (context.state.scope.get(id.name));
133131
const proxied = rune === '$state' && should_proxy(value, context.state.scope);
134132
const is_state = is_state_source(binding, context.state.analysis);
135-
if (proxied && is_state) {
136-
value = b.call('$.assignable_proxy', value, options);
137-
} else if (proxied) {
138-
value = b.call('$.proxy', value, options);
139-
} else if (is_state) {
140-
value = b.call('$.state', value, options);
133+
134+
if (proxied) {
135+
return b.call(is_state ? '$.assignable_proxy' : '$.proxy', value, options);
141136
}
137+
138+
if (is_state) {
139+
return b.call('$.state', value, options);
140+
}
141+
142142
return value;
143143
};
144144

0 commit comments

Comments
 (0)