Reputation: 915
I have a simple class User
and I am using ES5:
/**
* @property {number} id
* @property {string} username
* @property {string} password
* @property {string} email
*/
class User {
constructor(obj) {
...
}
}
However I cannot get VSCode's intellisense to hint any of the instance properties if I type say:
let a = new User();
a.| <-- Here intellisense should hint me id, username, etc...
Intellisense will only hint properties if I explicitly declare them in the constructor like so:
constructor(obj) {
this.id = 1;
this.username = '';
}
How can I write the JSDoc in the correct form?
Upvotes: 4
Views: 2097
Reputation: 69
Try this:
class User {
/** @type {number} */
id
/** @type {string} */
username
/** @type {string} */
password
/** @type {string} */
email
constructor(obj) {
// ...
}
}
Upvotes: 6