TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Js doc overloads

Open apendua opened this issue 3 years ago • 2 comments

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.

apendua avatar Sep 15 '22 14:09 apendua

CLA assistant check
All CLA requirements met.

ghost avatar Sep 15 '22 14:09 ghost

Looking forward to this!

ValeTheVioletMote avatar Oct 11 '22 00:10 ValeTheVioletMote

Closing this PR in favor of: https://github.com/microsoft/TypeScript/pull/51234

apendua avatar Oct 19 '22 20:10 apendua