有申报通过JSDoc语法类型参数中的javascript打字稿了解
答
是的,你可以指定类型在JavaScript中JSDoc为打字稿编译器使用...
/** @type {Window} */
var myWin;
/** @type {Event} */
var myEvent;
/**
* @param myStr {string} my parameter
* @return {string} returns a string
*/
function myFunction(myStr){
return myStr;
}
可在打字稿2.3及更高版本。
使用泛型类型参数:
/**
* @template T
* @param {T} thing
* @return {T}
*/
function getThing(thing){
return thing;
}
问题是关于类型** **参数:https://www.google.com/search?q=type+parameters+typescript –
作为泛型类型参数? – Fenton
是的,除非你知道一些其他类型参数 –