如何在VS Code中为单个变量启用类型注释

据我所知,VS Code已经支持TypeScript和JavaScript中的类型注释,但是在VS Code无法正确理解引用者的情况下,如何启用它或将其正确用于内联变量?

这是我的代码:

export const TooltipModule = {
  init() {
    this.tooltipelements = document.getElementsByClassname('tooltip')
    if (this.tooltipelements.length > 0) {
      this.enableTooltips()
    }
  },enableTooltips() {
    /** @var {Element} tp */
    for (const tp of this.tooltipelements) {
      new Tooltip(tp /* no type annotation here */,{
        placement: 'bottom',title: 'Top',})
    }
  },}

如何在VS Code中为单个变量启用类型注释

我也尝试使用@type@param

cyc51314210 回答:如何在VS Code中为单个变量启用类型注释

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3117345.html

大家都在问