如何解决VSCode:IntelliSence:JSDoc:不识别类实例类型
我有两个文件。在 find-python.js
中,我导出了 PythonFinder
类。在第二个文件 test-find-python.js
中,我有 this
为 PythonFinder
的函数。它的构造器是从 find-python.js
导入的。当我输入 @this {PythonFinder}
时,IntelliSence 无法识别 @this
是 PythonFinder 的实例(显示为 any
。我认为 IntelliSence 找不到它)。但进一步在我分配给 var new PythonFinder()
的代码和 IntelliSence 正确推断类型(即 PythonFinder
)
这里有一些代码:
find-python.js
module.exports.test = {
PythonFinder: PythonFinder,findPython: findPython
}
test-find-python.js
const findPython = require('../lib/new-find-python')
const PythonFinder = findPython.test.PythonFinder
/** hover over PythonFinder in next line: any
* @this {PythonFinder} recognized as any
*/
function testExecFileVersion(exec,args,options,callback) {
//(this: typeof PythonFinder)
this
//some code
}
//some more code
const pythonFinderInstance = new PythonFinder(null,callback)
//recognized as PythonFinder instance. IntelliSence display(const pythonFinderinstance: PythonFinder)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。