[英]is there a way to declare a type parameter via JSDoc syntax in javascript for typescript to understand
this document: 这个文件:
doesn't mention type parameters 没有提到类型参数
Questions: 问题:
Yes, you can specify types with JSDoc in JavaScript for the TypeScript compiler to use... 是的,您可以在JavaScript中使用JSDoc指定类型,以便TypeScript编译器使用...
/** @type {Window} */
var myWin;
/** @type {Event} */
var myEvent;
/**
* @param myStr {string} my parameter
* @return {string} returns a string
*/
function myFunction(myStr){
return myStr;
}
Available in TypeScript 2.3 and later. 在TypeScript 2.3和更高版本中可用。
Using generic type parameters: 使用通用类型参数:
/**
* @template T
* @param {T} thing
* @return {T}
*/
function getThing(thing){
return thing;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.