【发布时间】:2025-12-30 06:40:04
【问题描述】:
我正在尝试 jscodeshift,但每当我尝试插入新表达式时,我都会收到以下错误
{operator: ==, left: [object Object], right: [object Object], loc: null, type: BinaryExpression, comments: null} does not match type string
这是我的小测试中的内容:
var testBinary = j.binaryExpression("==", j.literal(2), j.literal(3))
return j(file.source)
.find(j.IfStatement)
.insertBefore(testBinary)
.toSource();
你可以在这里试一试https://astexplorer.net/#/P6euf9XIlR/1
如果我使用 j(file.source).find().replaceWith() 它没有任何问题。
我在这里做错了什么?
【问题讨论】:
-
这实际上看起来像错误,或者至少是我需要进一步调查的东西。请在github.com/facebook/jscodeshift 提出问题。
-
我在这里遇到了一个问题:github.com/facebook/jscodeshift/issues/161
标签: javascript runtime-error jscodeshift