title: TypeScript and Iterator: Type 'IterableIterator<T>' is not an array type
body: <p>When I use the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield*" rel="noreferrer"><code>yield*</code> expression</a> on TypeScript, it always gets an error.</p>
  
  <blockquote>
    <p>Type 'IterableIterator' is not an array type.</p>
  </blockquote>
  
  <p>How can I set the types correctly without using <code>any</code> to avoid the errors?</p>
  
  <pre><code>function* g1(): IterableIterator&lt;number&gt; {
    yield 2;
    yield 3;
    yield 4;
  }
  
  function* g2(): IterableIterator&lt;number&gt; {
    yield 1;
    // ERROR: Type 'IterableIterator&lt;number&gt;' is not an array type.
    yield* g1();
    yield 5;
  }
  
  const iterator = g2();
  </code></pre>