Sinon fake/stub/spy 使用“导出类型”导出的类

我正在使用一个库来生成 Typescript 绑定,它会使用 export type { MyClass } from "./MyClass" 自动导出我想要伪造/存根/监视的类。

生成的bindings.ts

export type { MyClass } from "./MyClass";

index.test.ts 中,以下代码:

sinon.replace(MyClass.prototype,"someFunction",sinon.fake())

...抛出编译时 TS 错误:

'MyClass' cannot be used as a value because it was exported using 'export type'.ts(1362)

如果将 MyClass.someFunction 作为类型导出,是否有办法伪造/存根/监视 for(let i in testDB){ if("73453212502130754" == testDB[i].userID){ return console.log(testDB[i].ID) }else{ console.log("none") }

WAGXZ 回答:Sinon fake/stub/spy 使用“导出类型”导出的类

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/436.html

大家都在问