pull/15579/head
Rich Harris 6 months ago
parent a97465da21
commit e7fa79a5f6

@ -116,25 +116,17 @@ export function ClassBody(node, context) {
context.visit(definition.value.arguments[0], child_state) context.visit(definition.value.arguments[0], child_state)
); );
let options = if (field.kind === 'state' || field.kind === 'raw_state') {
definition.value.arguments.length === 2 let arg = definition.value.arguments[1];
? /** @type {Expression} **/ ( let options = arg && /** @type {Expression} **/ (context.visit(arg, child_state));
context.visit(definition.value.arguments[1], child_state)
)
: undefined;
let proxied = should_proxy(init, context.state.scope);
value = value =
field.kind === 'state' field.kind === 'state' && should_proxy(init, context.state.scope)
? should_proxy(init, context.state.scope)
? b.call('$.assignable_proxy', init, options) ? b.call('$.assignable_proxy', init, options)
: b.call('$.state', init, options) : b.call('$.state', init, options);
: field.kind === 'raw_state' } else {
? b.call('$.state', init, options) value = b.call('$derived', field.kind === 'derived_by' ? init : b.thunk(init));
: field.kind === 'derived_by' }
? b.call('$.derived', init)
: b.call('$.derived', b.thunk(init));
} else { } else {
// if no arguments, we know it's state as `$derived()` is a compile error // if no arguments, we know it's state as `$derived()` is a compile error
value = b.call('$.state'); value = b.call('$.state');

Loading…
Cancel
Save