Reputation: 602
I'm adding JSDoc function documentation and am having trouble getting my documentation comments to appear when importing the functions with an absolute page path.
JSDoc function:
/**
* Adds two numbers together and returns that value
* @param {number} a
* @param {number} b
* @return {number} returns the value of a plus b
*/
function addNums (a, b) {
return a + b;
}
export { addNums }
Works with relative page path:
import { addNums } from './addNums'
Doesn't work with absolute page path:
import { addNums } from '~/lib/helpers/addNums'
Screen shots of what it looks like when I change the path from absolute to relative in my actual code:
Absolute page path:
Relative page path:
I've tried the solution listed on this SO thread: How do I get VSCode to recognize current package Javascript imports?
Unfortunately that did not work so Im wondering how to get JSDoc to recognize my absolute page paths and not the relative page paths that I define upon import. Thanks!
Upvotes: 1
Views: 1301
Reputation: 602
Figured it out. So this was an issue with the way we configured our webpack to recognize the ~
//webpack config
config.resolve.alias = {
...config.resolve.alias,
'~': path.resolve(__dirname)
}
I believe normally JSdoc doesn't have a problem resolving absolute file paths but in my case I added a tsconfig.json file:
///tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",
"paths": {
"~/*": ["*"]
}
}
}
This did the trick. Apologize if this confused anyone else, I wasn't aware of the webpack config until after this post but in the off-chance someone else has a similar configuration and is trying to get JSDoc to work, this is the solution!
Upvotes: 1