小编Clo*_* Fu的帖子

无法在类型参数上访问打字稿私有或受保护成员“某物”

class SomeClass<T extends string> {
  protected someMethod(): void {

  }

  protected someOtherMethod(): ReturnType<this["someMethod"]> { 
  // Private or protected member 'someMethod' cannot be accessed on a type parameter.ts(4105)


  }
}
Run Code Online (Sandbox Code Playgroud)

有没有办法在类本身中引用受保护的类成员的类型?

oop class this typescript typescript-typings

5
推荐指数
1
解决办法
209
查看次数

标签 统计

class ×1

oop ×1

this ×1

typescript ×1

typescript-typings ×1