pull/16060/head
Rich Harris 4 months ago
parent ca3330ca27
commit 520d3fcb14

@ -3,6 +3,7 @@
/** @import { Context } from '../types' */ /** @import { Context } from '../types' */
import * as b from '#compiler/builders'; import * as b from '#compiler/builders';
import { dev } from '../../../../state.js'; import { dev } from '../../../../state.js';
import { get_parent } from '../../../../utils/ast.js';
import { get_name } from '../../../nodes.js'; import { get_name } from '../../../nodes.js';
/** /**
@ -76,23 +77,21 @@ export function ClassBody(node, context) {
if (dev) value = b.call('$.tag', value, b.literal(name)); if (dev) value = b.call('$.tag', value, b.literal(name));
body.push(b.prop_def(definition.key, value)); body.push(b.prop_def(definition.key, value));
} else if (field.node === definition) { } else if (field.node === definition) {
const member = b.member(b.this, field.key); let call = /** @type {CallExpression} */ (context.visit(field.value, child_state));
if (dev) {
const declaration = /** @type {ClassDeclaration | ClassExpression} */ (
get_parent(context.path, -1)
);
call = b.call('$.tag', call, b.literal(`${declaration.id?.name ?? '[class]'}.${name}`));
}
const member = b.member(b.this, field.key);
const should_proxy = field.type === '$state' && true; // TODO const should_proxy = field.type === '$state' && true; // TODO
const call = /** @type {CallExpression} */ (context.visit(field.value, child_state));
body.push( body.push(
b.prop_def( b.prop_def(field.key, call),
field.key,
dev
? b.call(
'$.tag',
call,
b.literal(
`${/** @type {ClassDeclaration | ClassExpression} */ (context.path.at(-1))?.id?.name ?? '[class]'}.${field.key.name}`
)
)
: call
),
b.method('get', definition.key, [], [b.return(b.call('$.get', member))]), b.method('get', definition.key, [], [b.return(b.call('$.get', member))]),

Loading…
Cancel
Save