#50.typeScript

1.typeScript接口

类实现了一个接口
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://mbd.baidu.com/ma/s/25EfgZUB
https://blog.csdn.net/qq_33221861/article/details/112369522
https://www.cnblogs.com/jing-zhe/p/13061969.html

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容