#50.ts

1.ts

https://blog.csdn.net/lan7798/article/details/127607160
https://blog.csdn.net/yasinawolaopo/article/details/122472943

1.1typeScript接口

类实现了一个接口
https://blog.csdn.net/u014388408/article/details/130789117

interface IWithLength {
  length: number
}
function echoWithLength<T extends IWithLength>(arg: T): T {
  console.log(arg.length)
  return arg
}
const len01 = echoWithLength('abc') // 3
const len02 = echoWithLength({ length: 12 }) // 12
const len03 = echoWithLength([1, 2, 3]) // 3

2.泛型

https://blog.csdn.net/qq_40280582/article/details/112444461
https://blog.csdn.net/qq_33221861/article/details/112369522
https://www.cnblogs.com/jing-zhe/p/13061969.html
在调用泛型函数或实例化时,需要在尖括号内指定类型参数的具体类型
https://blog.csdn.net/qq_34185872/article/details/130551882

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容