Back to Type Challenges

README

questions/02828-hard-classpublickeys/README.md

latest1.3 KB
Original Source
<!--info-header-start--><h1>ClassPublicKeys </h1><blockquote><p>by jiangshan <a href="https://github.com/jiangshanmeta" target="_blank">@jiangshanmeta</a></p></blockquote><p><a href="https://tsch.js.org/2828/play" target="_blank"></a> </p><!--info-header-end-->

Implement the generic ClassPublicKeys<T> which returns all public keys of a class.

For example:

ts
class A {
  public str: string
  protected num: number
  private bool: boolean
  getNum() {
    return Math.random()
  }
}

type publicKeys = ClassPublicKeys<A> // 'str' | 'getNum'
<!--info-footer-start-->

<a href="../../README.md" target="_blank"></a> <a href="https://tsch.js.org/2828/answer" target="_blank"></a> <a href="https://tsch.js.org/2828/solutions" target="_blank"></a> <!--info-footer-end-->