Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 285
Jonathan Moffatt Avatar asked Oct 02 '22 02:10

Jonathan Moffatt


1 Answers

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"); 
like image 151
Ryan Cavanaugh Avatar answered Oct 12 '22 22:10

Ryan Cavanaugh