2

I have two JavaScript repos, libA and libB. In libB, I have a module, utilities.js:

/**
 * @class
 * @classdesc Class for doing stuff
 */
class MyClass {...}

Now in libA, I have a module, defs.js:

/**
 * @typedef {Object} UtilitiesFromB
 * @property {import("libB/utilities").MyClass} myClass - An instance of MyClass
 */

This does NOT work. However, if use @typedef on MyClass, then it does work (but I don't want to do that, since @typedef has no way of defining object methods, only properties).

/**
 * @typedef {Object} MyClass
 * @class
 * @classdesc Class for doing stuff
 */
class MyClass {...}

How do I get the type definition I created in libA/defs.js to be able to correctly reference MyClass as a property?

John Doe
  • 159
  • 9
  • Perhaps this question helps? https://stackoverflow.com/q/45836847/1244884 – customcommander Feb 27 '21 at 21:32
  • Maybe this answer would work for you https://stackoverflow.com/questions/43183450/jsdoc-typedef-in-a-separate-file#answer-55306135. Basically you need to require() one file from another one for `MyClass` to become available – Vitalii Mar 04 '21 at 22:57

0 Answers0