TypeScript
TypeScript copied to clipboard
Js doc overloads
Fixes #25590
Since there was no final consensus, I ended up using a new @overload tag to ensure backwards compatibility, e.g.
/**
* @overload
* @param {number} x
* @returns {'number'}
*/
/**
* @overload
* @param {string} x
* @returns {'string'}
*/
/**
* @overload
* @param {boolean} x
* @returns {'boolean'}
*/
/**
* @param {unknown} x
* @returns {string}
*/
function typeName(x) {
return typeof x;
}
I would be happy to modify the implementation if someone suggests a better approach.
Looking forward to this!
Closing this PR in favor of: https://github.com/microsoft/TypeScript/pull/51234