Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

233
Views
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!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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...

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!