typescript 如何在原生数据结构上进行扩展;
文章目录
// type.d.ts (global scope)
declare global{
interface Array{
customFunc(args)=>any;
}
}
// type.ts
Array.prototype.customFunc = (...args) => {
return
}
PS:在这个基础上对泛型进行补充会让这更perfect
// type.d.ts (global scope)
declare global{
interface Array{
customFunc(args)=>any;
}
}
// type.ts
Array.prototype.customFunc = (...args) => {
return
}
PS:在这个基础上对泛型进行补充会让这更perfect
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论