我的代码是:
Object.keys(res.body.data).should.containEql('id')
TypeScript 给我的错误是
Property 'should' does not exist on type 'string[]'.
那么如何将 should
与 TypeScript 一起使用呢?
最佳答案
您缺少 should 库的导入。基本上,您需要导入 import 'should'
才能访问 should 方法。
我已经测试了这段代码并且它有效!如果我评论导入,我遇到了与您相同的问题。
import 'should';
describe('test', () => {
it('should must work', () => {
Object.keys({ a: 1, b: 2 }).should.containEql('b');
})
})
关于typescript - 使用 TypeScript 的 should.js 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50496982/