多个文件 #1

Open
yystopf wants to merge 38 commits from API-2.0 into master
1 changed files with 5 additions and 1 deletions
Showing only changes of commit f447bb8989 - Show all commits

View File

@ -3,6 +3,10 @@ import * as babel from '@babel/core';
import { Option } from './types'; import { Option } from './types';
import type { Scope } from '@babel/traverse'; import type { Scope } from '@babel/traverse';
const DECORATOR_PROPS = 'Prop';
const DECORATOR_CHILDREN = 'Children';
const DECORATOR_WATCH = 'Watch';
function replaceFnWithClass(path: NodePath<t.FunctionDeclaration>, classTransformer: ClassComponentTransformer) { function replaceFnWithClass(path: NodePath<t.FunctionDeclaration>, classTransformer: ClassComponentTransformer) {
const originalName = path.node.id.name; const originalName = path.node.id.name;
const tempName = path.node.id.name + 'Temp'; const tempName = path.node.id.name + 'Temp';
@ -214,7 +218,7 @@ class ClassComponentTransformer {
*/ */
transformWatch(node: t.LabeledStatement) { transformWatch(node: t.LabeledStatement) {
const id = this.functionScope.generateUidIdentifier(DECORATOR_WATCH.toLowerCase()); 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))]; method.decorators = [this.t.decorator(this.t.identifier(DECORATOR_WATCH))];
this.addProperty(method); this.addProperty(method);
} }