我下面有JavaScript代码,并且根据Typescript Docs JSDoc Reference,我使用TypeScript编译器(TSC)提供类型检查。
const assert = require('assert');
const mocha = require('mocha');
mocha.describe('Array', () => {
mocha.describe('#indexOf()', () => {
mocha.it('should return -1 when the value is not present',
/** */
() => {
assert.strictEqual([1, 2, 3].indexOf(4), -1);
});
});
});
我看到此错误:
Assertions require every name in the call target to be declared with an explicit type annotation.ts(2775)
SomeFile.test.js(2, 7): 'assert' needs an explicit type annotation.
您需要为变量添加JSDoc类型注释,assert
例如下面的示例。您可以根据需要添加更具体的类型{any}
。
/** @type {any} */
const assert = require('assert');
有关更多信息,请参见此Github问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句