gpt4 book ai didi

typescript - 使用 TypeScript 的 should.js 问题

转载 作者:搜寻专家 更新时间:2023-10-30 21:08:10 34 4
gpt4 key购买 nike

我的代码是:

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/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com