Skip to content

Commit 896dfc9

Browse files
committed
somehow forgot to add support for class fields
1 parent 039d2c8 commit 896dfc9

File tree

1 file changed

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

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
/** @import { CallExpression, ClassBody, MethodDefinition, PropertyDefinition, StaticBlock } from 'estree' */
1+
/** @import { CallExpression, ClassBody, ClassDeclaration, ClassExpression, MethodDefinition, PropertyDefinition, StaticBlock } from 'estree' */
22
/** @import { StateField } from '#compiler' */
33
/** @import { Context } from '../types' */
44
import * as b from '#compiler/builders';
5+
import { dev } from '../../../../state.js';
56
import { get_name } from '../../../nodes.js';
67

78
/**
@@ -73,11 +74,19 @@ export function ClassBody(node, context) {
7374
const member = b.member(b.this, field.key);
7475

7576
const should_proxy = field.type === '$state' && true; // TODO
76-
77+
const call = /** @type {CallExpression} */ (context.visit(field.value, child_state));
7778
body.push(
7879
b.prop_def(
7980
field.key,
80-
/** @type {CallExpression} */ (context.visit(field.value, child_state))
81+
dev
82+
? b.call(
83+
'$.tag_source',
84+
call,
85+
b.literal(
86+
`${/** @type {ClassDeclaration | ClassExpression} */ (context.path.at(-1))?.id?.name ?? '[class]'}.${field.key.name}`
87+
)
88+
)
89+
: call
8190
),
8291

8392
b.method('get', definition.key, [], [b.return(b.call('$.get', member))]),

0 commit comments

Comments
 (0)