【发布时间】:2017-09-29 12:06:49
【问题描述】:
我想写一个模板函数来在 JsCodeShift 中创建新的变量。
有人有想法吗?或者一些更好的文档?
我根据this尝试了下面的代码。
const j = api.jscodeshift;
let test = j.variableDeclaration('let',
j.variableDeclarator(
j.identifier('test'),
null
)
);
但我得到了错误
Error: {id: [object Object], init: null, loc: null, type: VariableDeclarator,
comments: null} does not match field "declarations": [VariableDeclarator |
Identifier] of type VariableDeclaration
詹斯干杯
【问题讨论】: