typescript 如何在原生数据结构上进行扩展;

// type.d.ts (global scope)
declare global{
    interface Array{
        customFunc(args)=>any;
    }
}
// type.ts 
Array.prototype.customFunc = (...args) => {
        return 
}

PS:在这个基础上对泛型进行补充会让这更perfect

评论

暂无评论