ShouldJs Typescript问题与承诺

时间:2018-07-19 16:38:08

标签: typescript promise should.js

仅在尝试使用.rejected() / .fufilled()语法时,我才应该在应该使用typejs的打字稿中出现编译错误

Promise.resolve().should // is fine, is an Assertion
Promise.resolve().should.rejected // is fine, is a Function
Promise.resolve().should.rejected() // TS2349 Cannot invoke expression whose type lacks a call signature. Type Promise<any> has no compatible call signatures

我试图像这样强制转换为PromisedAssertion(<PromisedAssertion>Promise.resolve())(Promise.resolve() as PromisedAssertion)无效。我该如何解决?

.should可以正常工作

1 个答案:

答案 0 :(得分:0)

在应该转换为any的同时,创建了针对应回购的问题