I have issue with VS Code, TypeScript (not used directly) and JSDoc where I re-export a class from a library through a namespace object to users code and type is not properly recognized in all uses:
path.js (class definition):
'use strict';
class Path {}
module.exports = Path;
paths.js (namespace):
'use strict';
module.exports = {
'Path': require('./path') // Re-export class
};
Actual user code:
'use strict';
const paths = require('./paths');
const p = new paths.Path(); // Works fine
/**
* @param {paths.Path} path <-- Error
*/
function drawPath(path) {
}
When using paths.Path
as a type inside @type
or @param
I get TS error saying:
‘paths.Path’ refers to a value, but is being used as a type here. Did you mean ‘typeof paths.Path’? ts(2749)
I’m using regular JS code with JSDoc comments and have jsconfig.json file
How can I avoid this error so that a class in a namespace object could be used as a type in JSDoc comments?