diff --git a/packages/transpiler/class-transformer/src/pluginProvider.ts b/packages/transpiler/class-transformer/src/pluginProvider.ts index 3124042f..0766f562 100644 --- a/packages/transpiler/class-transformer/src/pluginProvider.ts +++ b/packages/transpiler/class-transformer/src/pluginProvider.ts @@ -3,6 +3,10 @@ import * as babel from '@babel/core'; import { Option } from './types'; import type { Scope } from '@babel/traverse'; +const DECORATOR_PROPS = 'Prop'; +const DECORATOR_CHILDREN = 'Children'; +const DECORATOR_WATCH = 'Watch'; + function replaceFnWithClass(path: NodePath, classTransformer: ClassComponentTransformer) { const originalName = path.node.id.name; const tempName = path.node.id.name + 'Temp'; @@ -214,7 +218,7 @@ class ClassComponentTransformer { */ transformWatch(node: t.LabeledStatement) { const id = this.functionScope.generateUidIdentifier(DECORATOR_WATCH.toLowerCase()); - const method = this.t.classMethod('method', id, [], this.t.blockStatement([node.body]), false, false); + const method = this.t.classMethod('method', id, [], this.t.blockStatement([node]), false, false); method.decorators = [this.t.decorator(this.t.identifier(DECORATOR_WATCH))]; this.addProperty(method); }