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