How to “import” a typedef from one file to another in JSDoc using Node.js?

后端 未结 1 1937
野趣味
野趣味 2020-12-25 11:55

Let\'s say I have a file named \"File1.js\". In this file, I export an object of objects and I give each object a typedef, like so.

/**
 * My typedef for eac         


        
相关标签:
1条回答
  • 2020-12-25 12:37

    Import the declared type in your file File2.js using the function import.

    const persons = require('./File1.js');
    
    /**
     * @typedef {import('./File1.js').MyObject1} MyObject1
     */
    
    class File2 {
    ...
    

    It works for me.

    0 讨论(0)
提交回复
热议问题