0

I have somewhat of the following code:

export class Logger {
   constructor(label = null, options = {}) {
      if (!winston.loggers.has(label)) {
         winston.loggers.add(
            label,
            { /* ...default options */ }
         );
      }

      return winston.loggers.get(label);
   }

   // some other function...
}

Here, my class returns a custom object which is a Winston logger object. But when I import this class in my other files and create a new object with it (const logger = new Logger()), the auto-suggestion show only the function in the class i.e // some other function. Now, since my class returns a Winston logger instance, I want to be able to document it with JS doc so that I get my auto-suggestion back.

Is there a way I can achieve this with JS doc, to define a custom type of object that an already defined class returns?

Kiran
  • 340
  • 2
  • 11

1 Answers1

0

are you using typescript compiler? If then you can define a logger.types.ts types file and import it in jsdoc returns annotation.

/**
 * Logger Component of the form
 * @returns {import("./logger.types.ts").LoggetProps}
 */

export interface LoggetProps extends winston {
     //example props
     isError: boolean


}
Velu S Gautam
  • 822
  • 9
  • 18