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) } }
GitHub: abell123456/Topics
![abell123456 profile picture](/abell123456.png?size=40)
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); }
+ 11 other calls in file
babel-types.identifier is the most popular function in babel-types (4076 examples)