如何在Obect原型上声明返回与对象实例相同类型的typescript属性



我将此属性添加到我的对象原型:

declare global {
interface Object {
// how can i declare that the result is not just any 
// but the very same type as the object instance?
get stripped(): any 
}
}

我不想返回任何,而是想声明stripped返回的对象类型与对象实例完全相同。我该怎么做?

不太相关,但此属性会删除所有未定义值的属性。

使用此参数:

stripped<T>(this: T): T,

最新更新