0
我想编写一个模板函数来在JsCodeShift中创建新的变量。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
干杯延
https://www.toptal.com/javascrip t/write-code-to-rewrite-your-code 是最有帮助的文章 –