From 896dfc9ae6f686f4018e9943947ec3e78c2eb0d2 Mon Sep 17 00:00:00 2001 From: ComputerGuy <63362464+Ocean-OS@users.noreply.github.com> Date: Sun, 1 Jun 2025 23:31:45 -0700 Subject: [PATCH] somehow forgot to add support for class fields --- .../3-transform/client/visitors/ClassBody.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/ClassBody.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/ClassBody.js index 71a8fc3d05..36be53ca4e 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/ClassBody.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/ClassBody.js @@ -1,7 +1,8 @@ -/** @import { CallExpression, ClassBody, MethodDefinition, PropertyDefinition, StaticBlock } from 'estree' */ +/** @import { CallExpression, ClassBody, ClassDeclaration, ClassExpression, MethodDefinition, PropertyDefinition, StaticBlock } from 'estree' */ /** @import { StateField } from '#compiler' */ /** @import { Context } from '../types' */ import * as b from '#compiler/builders'; +import { dev } from '../../../../state.js'; import { get_name } from '../../../nodes.js'; /** @@ -73,11 +74,19 @@ export function ClassBody(node, context) { const member = b.member(b.this, field.key); const should_proxy = field.type === '$state' && true; // TODO - + const call = /** @type {CallExpression} */ (context.visit(field.value, child_state)); body.push( b.prop_def( field.key, - /** @type {CallExpression} */ (context.visit(field.value, child_state)) + dev + ? b.call( + '$.tag_source', + 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))]),