Closed
Description
#51234 introduced a new @overload
tag, but it doesn't have the same type-checking rules as TypeScript's overloads.
Namely that we ensure that for each overload, the implementation signature is assignable to that overload, allowing the return type to be bidirectionally assignable.
If we want the same results in checkJs
, then the following should error:
// @ts-check
/**
* @overload
* @param {number} x
* @returns {number}
*/
/**
* @param {string} x
* @returns {string}
*/
function wut(x) {
return String(x);
}
wut(123).toFixed(2);