title: How to use array.map with tuples in typescript?
body: <p>Whenever I use <code>array.map</code> on a tuple, Typescript infers it as a generic array. For instance, here are some pieces of a simple 3x3 sudoku game:</p>
  
  <pre class="lang-js prettyprint-override"><code>const _ = ' ' // a "Blank"
  
  type Blank = typeof _
  
  type Cell = number | Blank
  
  type Three = [Cell, Cell, Cell]
  
  type Board = [Three, Three, Three]
  
  const initialBoard: Board = [
      [_, 1, 3],
      [3, _, 1],
      [1, _, _],
  ]
  
  // Adds a `2` to the first cell on the first row
  function applyMove(board: Board): Board {
      // errors here
      const newBoard: Board =  board.map((row: Three, index: number) =&gt; {
          if (index === 0) return &lt;Three&gt; [2, 1, 3]
          return &lt;Three&gt; row
      })
      return newBoard
  }
  
  function applyMoveToRow(row: Three): Three {
      // return [2, 1, 3] // This works
      const newRow: Three = [
          2,
          ...row.slice(1, 3)
      ]
      return newRow
  }
  </code></pre>
  
  <p>The TS error is:</p>
  
  <pre><code>Type '[Cell, Cell, Cell][]' is missing the following properties from type 
   '[[Cell, Cell, Cell], [Cell, Cell, Cell], [Cell, Cell, Cell]]': 0, 1, 2 .  
  </code></pre>
  
  <p><a href="http://www.typescriptlang.org/play/#code/MYewdgzgLgBA+jAvDA5KmB6DMCGMBEAQgDY5gDW+AsAFC1QCeADgKYwlnlIyOsgBm8WvWZsAwi2LFuYAK4BbAEYsATjAA+7UhWE1ebACoALFSzbIA2hKkAaGNeJ2HAXV372IHCoAm3C8dMWOwCzYJMzVzoaUEhYAEswOKg4nGJCTx8ALg8vX0taGEKYCzg7AEY7AGZnGwKii0q7UpgymrrCiwr4JraaSNosGABBb28IXBgAAwAmSZ4QHiM2fjiVaBhgSWlwReXV9ZUQAHdaflkwYGSdnCYmYgYAWRAANxYACkUM72z03IBKH5fGAAb3aG3A6zALCOvyyOR83Bgn1yADp5Dc3m9DkdsiEgjAEt4WAAPbJyJSqP5IAB8ILBRQJgjehJJSEQyAADFTTFBZCowDAADx42kWablKqRBkMnl8gXC8IsWnYsEAXz+YNl-JgUJhX1oqt0ZwuVwFNzujxeLAMIAASscscdcYqATA8XSaAzBlqBWKJTBqphsMY4uMjiAVOQIGCYpDofacW7FX56UVxanCiis9iURBiHFNm8upUNZ6ilKij6dfHjgagA" rel="noreferrer">here</a> it is in a TS Playground.</p>
  
  <p>Is there any way to tell typescript that, when I'm mapping over a tuple, it's going to return a tuple of the same kind, instead of just an array? I've tried being very explicit, annotating all of my return values, etc, but it's not doing the trick.</p>
  
  <p>There's a discussion on the Typescript github about this: <a href="https://github.com/Microsoft/TypeScript/issues/11312" rel="noreferrer">https://github.com/Microsoft/TypeScript/issues/11312</a></p>
  
  <p>But I haven't been able to get a solution out of it.</p>