How can I properly document the function in order for vscode-intellisense to recognize that getObject("player")
returns a Player
type and getObject("bullet")
returns a Bullet
type?
/**
* @param {string} type
* @return {????}
*/
function getObject(type) {
switch (type) {
case 'player': return new Player();
case 'bullet': return new Bullet();
}
}
A good example to follow would be the functionality of document.createElement(...)
.
document.createElement("canvas")
=> intellisense recognizes it as a HTMLCanvas
type.