TypeScript Version: 2.4.1 and 2.5.0-dev.20170719
Code
// @ts-check
var obj = {
/**
* hover: "(property) no_workaround: <T>(a: any[]) => any"
* T in "param" and "returns" say "Cannot find name 'T'."
* @template T
* @param {T[]} a
* @returns {T}
*/
no_workaround: function (a) {
return a[0];
},
yes_workaround:
/**
* this works correctly: "(property) yes_workaround: <T>(a: T[]) => T"
* @template T
* @param {T[]} a
* @returns {T}
*/
function (a) {
return a[0];
}
};
// correct return type - "Property 'nonexistent' does not exist on type 'number'."
obj.yes_workaround([1]).nonexistent();
// return type is any so there's no type checking
obj.no_workaround([1]).nonexistent();
Expected behavior:
the type of no_workaround should be the same as yes_workaround (<T>(a: T[]) => T)
Actual behavior:
it's something else: <T>(a: any[]) => any
the type parameter from @template is added to the function's signature but it seems like it's not in scope for the other jsdoc tags (so they show an error and use any), unless the comment block appears right before the function expression like in yes_workaround
TypeScript Version: 2.4.1 and 2.5.0-dev.20170719
Code
Expected behavior:
the type of
no_workaroundshould be the same asyes_workaround(<T>(a: T[]) => T)Actual behavior:
it's something else:
<T>(a: any[]) => anythe type parameter from
@templateis added to the function's signature but it seems like it's not in scope for the other jsdoc tags (so they show an error and useany), unless the comment block appears right before the function expression like inyes_workaround