title: Defining a list of tuples with optional first and last elements
body: <p>I'm trying to model some data in TypeScript that looks like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>// Sometimes we lookup the min/max dynamically, so we have keywords for them.
  const intervalA: NumericInterval = [['$min', 3], [3, 5], [5, '$max']];
  
  // Other times, we know the min/max and provide them inline
  const intervalB: NumericInterval = [[0, 3], [3, 5], [5, 7]];
  </code></pre>
  
  <p>I've tried to define <code>NumericInterval</code> as:</p>
  
  <pre class="lang-js prettyprint-override"><code>type MinInterval = ['$min', number];
  type MaxInterval = [number, '$max'];
  type Interval = [number, number];
  type NumericInterval = [MinInterval?, ...Interval[], MaxInterval?];
  
  </code></pre>
  
  <p>However, TypeScript is doesn't like it because <code>A rest element must be last in a tuple</code>.</p>
  
  <p>Is there a better way to express this schema?</p>