0👍
✅
It more or less depends on what IDE you’re using. I’m using VSCode and it understands types very well, I only need to make explicit jsdoc comments under certain situations.
So with export default, instead of exporting the object like:
export default {
/** @var SomeClass */
someObject: {},
/** @var SomeOtherClass
someOtherObject: {},
/** String[] */
evenMore: []
<etc...>
}
you need to do:
const export_me = {
/** @var SomeClass */
someObject: {},
/** @var SomeOtherClass
someOtherObject: {},
/** String[] */
evenMore: []
}
export default export_me
And with functions, if you’re not destructuring them in the parameters, you will need to do something like this
/**
@typedef {{
name: string,
age: number
}} Person
@param {Person} person
@param {number} speed
@returns {number}
*/
export function runningMan (person, speed) {
const {
name,
age
} = person;
}
I do not use @property
because it doesn’t work in vscode.
Source:stackexchange.com