vscode IntelliSense do do jsdoc检测对象类型

发布于 2025-01-26 06:33:59 字数 894 浏览 1 评论 0原文

我在项目中使用JavaScript和Typescript的JSDOC使用JSDOC,并且我注意到,如果将参数定义为object类型,则在JS文件中,VSCODE INTELLISENSE将其显示为type 任何。

/**
 * @param {Object} options - 
 */
function testFunc(options) {
  return options;
}

如果我使用对象,则似乎可以正常工作。

从我阅读的内容中noreferrer“> typescript手册和 jsdoc 对象不应该有任何区别,我希望VSCODE IntelliSense在悬停时正确显示为Object类型。

此外,与其他类型不同,返回类型不是自动推断出的,并且显示为任何类型。

I'm using JSDoc in my project having both javascript and typescript, and I notice that in my js file if a parameter is defined as Object type then VSCode intellisense shows it as type any.

/**
 * @param {Object} options - 
 */
function testFunc(options) {
  return options;
}

vscode intellisense Object

If I use object then it seems to work fine.
vscode intellisense object

From what I've read typescript handbook and jsdoc Object or object shouldn't make any difference, and I'm expecting vscode intellisense to show it properly as object type upon hover.

Furthermore, unlike other types, return type is not inferred automatically and it shows as any type.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱已欠费 2025-02-02 06:33:59

对象是打字稿的东西,当您在LowerCase中传递Object时,它将类Object作为现有。当您说@Param可以在JavaScript中采用对象时,就像说它可以取任何东西,因为没有区别。在Typescript中,当您仅想要Objects而不是号码>数字>, arrays & 布尔值 ...

The Object is a typescript thing, when you pass object in lowercases, it considers the class object as existing. When you says the @param can take an Object in javascript, it's like saying it can take anything, because there is no difference. In TYPESCRIPT, the type Object is needed when you only want Objects and not Numbers, Arrays & booleans...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文