【问题标题】:Visual Studio intellisense from Typescript jsdoc is not working with fat arrow functionsTypescript jsdoc 中的 Visual Studio intellisense 不适用于粗箭头函数
【发布时间】:2014-01-05 22:37:00
【问题描述】:

Typescript intellisense 可以很好地解决这个问题:

class SampleClass {
    /**
     * Does stuff
     *
     * @param blah stuff needing done 
     */
    public doStuff(blah: string) {
    }
}

var sample = new SampleClass();
// intellisense works correctly and shows parameter description:
sample.doStuff("hello"); 

但是切换到使用粗箭头似乎破坏了 jsdoc 智能感知(方法签名仍然出现,但没有任何 jsdoc 描述出现):

class SampleClass2 {
    /**
     * Does stuff
     *
     * @param blah stuff needing done 
     */
    public doStuff = (blah: string) => {
    }
}

var sample2 = new SampleClass2();
// intellisense gives the method signature still but no longer picks up any of the jsdoc descriptions:
sample2.doStuff("hello"); 

我正在使用 Visual Studio 2012 Update 4;打字稿 0.9.5。

这是一个错误,还是我需要为 jsdoc cmets 使用不同的语法?

【问题讨论】:

    标签: visual-studio-2012 typescript jsdoc arrow-functions


    【解决方案1】:

    我使用的是 Visual Studio 2013,因此我无法测试您所拥有的确切设置 - 但您应该获得任一示例的类型提示和自动完成功能。

    使用 JSDoc 的 TypeScript 游乐场的屏幕截图...

    【讨论】:

    • 他知道自动完成,他在谈论 cmets,是的,它似乎不起作用,在操场上尝试过。
    • 为我工作。添加了屏幕截图。
    • 操场上的行为与 Visual Studio 不太一致。正如史蒂夫指出的那样,操场确实显示了类描述(VS 没有)。但正如 AD.Net 所说,操场(和 VS)不显示参数说明。
    【解决方案2】:

    我真的很困惑为什么这在 TypeScript Playground 中有效。

    要在 Visual Studio 中进行这项工作,函数文档需要在函数表达式本身上:

    class SampleClass2 {
        public doStuff =
            /**
             * Does stuff
             *
             * @param blah stuff needing done 
             */
        (blah: string) => {
        }
    }
    
    var sample2 = new SampleClass2();
    sample2.doStuff("hello"); 
    

    【讨论】:

      猜你喜欢
      • 2019-05-07
      • 2016-07-14
      • 1970-01-01
      • 2022-01-21
      • 2012-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-21
      相关资源
      最近更新 更多