title: Get all value types of a double-nested object in TypeScript
body: <p>My question is similar to <a href="https://stackoverflow.com/questions/53662208/types-from-both-keys-and-values-of-object-in-typescript">Types from both keys and values of object in Typescript</a>, but with an additional layer of nesting:</p>
  
  <pre><code>interface Outer {
    a: {
      b: number
    },
    c: {
      d: string
    }
  }
  </code></pre>
  
  <p>And I'm only looking to retrieve the union type of all values, here <code>number | string</code>.</p>
  
  <p>Here's my stab:</p>
  
  <pre><code>type Values&lt;T extends Record&lt;string, any&gt;&gt; = T[keyof T]; // From previous SO answer
  
  type InnerValues&lt;
    T extends Record&lt;string, Record&lt;string, any&gt;&gt;,
    K extends keyof T
  &gt; = T[K][keyof T[K]];
  
  type All = Values&lt;Outer&gt;;
  type In = InnerValues&lt;Outer, keyof Outer&gt;; // expected number|string
  
  </code></pre>
  
  <p>but I have an error saying <code>Outer</code> doesn't have an index type.</p>
  
  <p><a href="https://www.typescriptlang.org/play/#code/JYOwLgpgTgZghgYwgAgPIFdJWQbwFDLJwBcuBhyARqSOgLaXQDc5Avi4QqfhcgCakAzmCigA5h2Ts8rPHjABPAA4oAanAA26CIIA8AFWQQAHpBB9ByAEoQEAeyh9dw0SDEAaIiAUA+H8gBeZH0AbQBrCAU7GGCAXRZ5ZRQASRAQaHUtHV1yQxMzC2tbBycXcU8be0dnEXKvXx93cgBpI1MIc0sIqJj9PH8g0ObY8Mjo4JDh+LlFFWQAQQ0NQORM7T0MLB8WWZSQFdT0qDXszehPbvGzqG3kAHo7tpUESD5kWgZoAB8ytzwgA" rel="noreferrer">Playground link.</a></p>