gpt4 book ai didi

javascript - 来自 JSDoc 的 Intellisense 不适用于 VSCode 中的导入类型

转载 作者:行者123 更新时间:2023-12-05 01:15:49 27 4
gpt4 key购买 nike

在 JSDoc 中使用 ES2015 类作为类型时,在通过 require 语句导入该类的文件中似乎无法正常工作。

在定义类的同一文件中工作时,一切都按预期工作(如下所示)。

An example of JSDoc typing working correctly in the same file

在不同的文件中工作时,该类似乎可以正确导入并显示其构造函数类型(如下所示)。

An example of an imported class working correctly

但是当我尝试使用该类进行输入时(如第一张图片中所做的那样),它不再将我的类视为有效类型。

An example of an imported class not being accepted as a type

这是我用于此示例的 jsconfig

{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"allowSyntheticDefaultImports": true
}
}

我只是在我的设置中遗漏了一些东西,还是这是预期的行为?

最佳答案

这个答案可能有点晚了,但你最后一张图片的第 6 行应该是:

@param {ExampleType} exampleType

使用小写“exampleType”,因为这就是函数中参数的名称。

关于javascript - 来自 JSDoc 的 Intellisense 不适用于 VSCode 中的导入类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40877203/

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