5

打字稿智能感知适用于此:

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 注释使用不同的语法?

4

2 回答 2

4

老实说,我很困惑为什么这在 TypeScript Playground 中有效。

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

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

var sample2 = new SampleClass2();
sample2.doStuff("hello"); 
于 2013-12-17T23:33:08.447 回答
0

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

带有 JSDoc 的 TypeScript 游乐场的屏幕截图...

在此处输入图像描述

于 2013-12-17T23:15:07.130 回答