How to use the ClassMethod function from babel-types
Find comprehensive JavaScript babel-types.ClassMethod code examples handpicked from public code repositorys.
83 84 85 86 87 88 89 90 91 92
const methodObj = insert[key]; const newAst = getTemplateAst(methodObj.body, {sourceType: 'script'}) // console.log(newAst) const params = checkParams(methodObj.argv, newAst) // const property = Types.ClassMethod('method', Types.identifier(methodObj.name), [], Types.BlockStatement(newAst)) // 转换出新的body插入就可以了 path.node.body.push(newAst) } }
9
11
0
GitHub: abell123456/Topics
200 201 202 203 204 205 206 207 208 209
}); const params = checkParams(argv, newAst); // 通过Types.ClassMethodAPI,生成方法AST const property = Types.ClassMethod('method', Types.identifier(name), params, Types.BlockStatement(newAst)); // 插入进AST path.node.body.push(property); }
1
9
3
+ 11 other calls in file
babel-types.identifier is the most popular function in babel-types (4076 examples)