Skip to content

Commit e7fa79a

Browse files
committed
simplify
1 parent a97465d commit e7fa79a

File tree

1 file changed

+9
-17
lines changed
  • packages/svelte/src/compiler/phases/3-transform/client/visitors

1 file changed

+9
-17
lines changed

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

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -116,25 +116,17 @@ export function ClassBody(node, context) {
116116
context.visit(definition.value.arguments[0], child_state)
117117
);
118118

119-
let options =
120-
definition.value.arguments.length === 2
121-
? /** @type {Expression} **/ (
122-
context.visit(definition.value.arguments[1], child_state)
123-
)
124-
: undefined;
125-
126-
let proxied = should_proxy(init, context.state.scope);
119+
if (field.kind === 'state' || field.kind === 'raw_state') {
120+
let arg = definition.value.arguments[1];
121+
let options = arg && /** @type {Expression} **/ (context.visit(arg, child_state));
127122

128-
value =
129-
field.kind === 'state'
130-
? should_proxy(init, context.state.scope)
123+
value =
124+
field.kind === 'state' && should_proxy(init, context.state.scope)
131125
? b.call('$.assignable_proxy', init, options)
132-
: b.call('$.state', init, options)
133-
: field.kind === 'raw_state'
134-
? b.call('$.state', init, options)
135-
: field.kind === 'derived_by'
136-
? b.call('$.derived', init)
137-
: b.call('$.derived', b.thunk(init));
126+
: b.call('$.state', init, options);
127+
} else {
128+
value = b.call('$derived', field.kind === 'derived_by' ? init : b.thunk(init));
129+
}
138130
} else {
139131
// if no arguments, we know it's state as `$derived()` is a compile error
140132
value = b.call('$.state');

0 commit comments

Comments
 (0)