问题描述
在ESDoc中使用ES2015类作为类型时,在通过require语句导入该类的文件中,它似乎无法正常工作.
When using a, ES2015 class as a type in JSDoc it does not appear to work correctly in files that import that class via a require statement.
在与定义类的文件相同的文件中工作时,所有内容均按预期工作(如下所示).
While working within the same file that the class was defined in, everything works as expected (shown below).
在不同文件中工作时,该类似乎可以正确导入并显示其构造函数的类型(如下所示).
While working within a different file the class appears to import correctly and show its constructor typing (shown below).
但是当我尝试使用该类进行输入时(如第一张图片所示),它不再将我的类视为有效类型.
But when I try to use the class for typing (As done in the first image) it no longer considers my class as a valid type.
这是我在此示例中使用的jsconfig
Here is the jsconfig I was using for this example
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"allowSyntheticDefaultImports": true
}
}
我只是在设置中丢失了某些东西吗?或者这是预期的行为?
Am I just missing something in my setup or is this the expected behavior?
推荐答案
这个答案可能有点晚,但是最后一张图片的第6行应显示为:
This answer may be a bit late, but line 6 of your last image should read:
@param {ExampleType} exampleType
使用小写的"exampleType",因为这是在函数中命名的参数.
With a lower case "exampleType", since that's what the param is named in the function.
这篇关于JSDoc中的Intellisense无法用于VSCode中的导入类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!