Reputation: 2401
I want to document a type that is defined in a node module (discord.js
in my case) so that VS Code can help me with autocompletion.
VS Code supports type hints with JSDoc and this should be the correct way to document the type of the parameter client
. Yet VS Code, when I hover over the parameter, says that it is of type any
.
(parameter) client: any
This is my code so far
module.exports = class Receiver {
/**
* @param {module:"discord.js".Client} client
*/
constructor(client) {
this.client = client
}
}
How can I make VS Code understand the correct type of the parameter? It should not be any
but Client
instead.
PS: I have installed the discord.js
module and can successfully use it.
Upvotes: 4
Views: 2309
Reputation: 2240
It's not official jsdoc.app syntax, but it works for IntelliSense/TypeScript:
module.exports = class Receiver {
/**
* @param {import("./discord.js").Client} client
*/
constructor(client) {
this.client = client
}
}
Upvotes: 1