我有一些使用经典JS类的旧代码,我想对它们进行类型检查。例如:
/**
* @constructor
*/
function Test() {
this.x = 1;
}
但是,当我运行tsc --noImplicitThis --noEmit --allowJs --checkJs test.js
输入check时,出现以下错误:
test.js:5:5 - error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
5 this.x = 1;
~~~~
我无法通过查看https://github.com/Microsoft/TypeScript/wiki/JsDoc-support-in-JavaScript或仅仅通过猜测来找到任何类型注释来解决此错误。有办法吗?
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句