'jsdoc class with @lends (or similar) not recognized by intellisense

I am currently working on a project that was written before es6 classes were a thing and therefor uses a class creation function for all of its classes.

I am using VSCode and thought, it would be nice to use some IntelliSense, so that instances show their methods, the parameters and return types, and so on, therefor I documented them using JSDoc.

I quickly found out that JSDoc allows Documentation of pre-es6-classes. The docs nearly include my problem, see jsdoc tag documentation: @lends. The given example shows the following:

/** @class */
var Person = makeClass(
    /** @lends Person.prototype */
    {
        /**
         * Create a `Person` instance.
         * @param {string} name - The person's name.
         */
        initialize: function(name) {
            this.name = name;
        },
        /**
         * Say something.
         * @param {string} message - The message to say.
         * @returns {string} The complete message.
         */
        say: function(message) {
            return this.name + " says: " + message;
        }
    }
);

Yet, when I copy-paste this example into an empty javascript file and add another line below, like

var p = new Person("");
p.say("")

My editor, VSCode, does no intellisense-hinting for p.say, the parameter message (which isn't recognized at all) and p and var Person is shown as type: any . I would have expected that p would have the type Person and that intellisense recognizes the class with its methods. Why isn't this the case, what am I doing wrong?

I already tried to add @type Person or some other tags, but I would like to avoid having a separate file like .d.ts just for type hinting or separating "documentation" and code to much. The documentation of a function foobar(foo, bar){ ... } with jsdoc works and type hinting is shown, but keeping the type information after variable assignments seem to be a problem.

(Obviously: Changing the entire project to a newer javascript version or even typescript is not an option.)

Thanks for any help in advance!



Solution 1:[1]

To whoever finds this question:
The main culprit seems to have been Visual Studio Code. Using IntelliJ's Webstorm IDE, the @lends notation works and name completion including type hinting are shown. If you, dear reader, have the same problem and are using VSCode, test another IDE, it may actually work...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 curious_capybara