title: How recursively get all keys of nested object?
body: <pre><code>type NestedObject = {
   amount: number,
   error: string | null,
   data: {
    rows: [],
    messages: {
     goodNews: string | null,
     badNews: string | null
    }
   }
  }
  
  //trying recursively get all keys 
  type AllKeys&lt;T, K extends keyof T&gt; = 
   T extends object ?
    T extends infer O ? 
     {keys: K | AllKeys&lt;O, keyof O&gt; : never
   : K
  
  type Test = AllKeys&lt;NestedObject, keyof NestedObject&gt;
  </code></pre>
  <p>as a result I have:</p>
  <pre><code>type Test = { keys: 'amount' | 'error' | 'data' | ... }
  </code></pre>
  <p>but I need to get:</p>
  <pre><code>type Test = { keys: 'amount' | 'error' | 'data' | 'rows' | 'messages' | 'goodNews' | 'badNews'}
  </code></pre>