假设我有以下文件
export default {
foo: 'bar'
}
如何使用 jscodeshift 转换此文件,以便将对象包装成如下函数:
export default () => ({
foo: 'bar'
})
我的主要问题是如何使用api.jscodeshift.arrowFunctionExpression()
,尤其是如何创建函数体。因为我认为我需要做的就是ObjectExpression
用具有ObjectExpression
作为其主体的函数替换。