Visual Studio intellisense from Typescript jsdoc is not working with fat arrow functions

4.6k Views Asked by At

Typescript intellisense works fine for this:

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"); 

However switching to use the fat arrow seems to break the jsdoc intellisense (the method signature still appears, but none of the jsdoc descriptions do):

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"); 

I'm using Visual Studio 2012 Update 4; TypeScript 0.9.5.

Is this a bug, or do I need to use a different syntax for the jsdoc comments?

2

There are 2 best solutions below

0
On BEST ANSWER

I'm honestly very confused why this works in the TypeScript Playground.

To have this work in Visual Studio, the function documentation needs to be on the function expression itself:

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

var sample2 = new SampleClass2();
sample2.doStuff("hello"); 
3
On

I'm using Visual Studio 2013, so I can't test the exact set-up that you have - but you should get the type-hinting and auto-completion for either example.

Screen shot from the TypeScript playground with JSDoc...

enter image description here