这在typescript中很好,但是我不想使用typescript,只使用babel,而不使用任何其他编译器。我的猜测是,target在el函数中是class而不是instance,而在使用typescript时并非如此。如果有人知道如何使用babel和不使用typescript来完成这项工作仅限babel演示: return function descriptor(target, key,dec) {
let value = t
因此,我学习了如何在typescript中进行扩展: interface Array<T> {}
Array.prototype.lastIndex =function (): number { return this.length - 1 } 但是如何让它变得更有价值呢?我找到了这个答案,但是代码不能编译泛型类型,而且这样写很难看,但是也许我在typescript:How to extend a typescript class with a