title: Remove items from beginning of function arguments with TypeScript
body: <p>I'm trying to make a generic that can remove the first <code>n</code> items from a list of parameters from a function. So say I have this type describing a function:</p>
  <pre class="lang-js prettyprint-override"><code>type Fn = (p1: string, p2: number, p3: boolean) =&gt; void;
  </code></pre>
  <p>I can easily get the parameters via:</p>
  <pre class="lang-js prettyprint-override"><code>type Params = Parameters&lt;Fn&gt;;
  </code></pre>
  <p>In another function, I want to reuse the arguments from that <code>Fn</code> type but be able to remove the first two. I've accomplished via:</p>
  <pre class="lang-js prettyprint-override"><code>type RemoveFirstTwo&lt;T extends unknown[]&gt; = ((...x: T) =&gt; void) extends (h: infer A, j: infer B, ...t: infer R) =&gt; void ? R : never;
  
  function bar(...rest: RemoveFirstTwo&lt;Params&gt;) {}
  
  bar(true); // ok
  bar('', 0, true); // error
  </code></pre>
  <p>Looking at my <code>RemoveFirstTwo</code> generic, I felt like I could make it a bit more generic but having a hard time. My thought is to make a <code>RemoveFirstNItems</code> generic and use it like:</p>
  <pre class="lang-js prettyprint-override"><code>function bar(...rest: RemoveFirstNItems&lt;Params, 2&gt;) {}
  </code></pre>
  <p>I'm having a hard time replacing my hardcoded generic with a more generic, generic.</p>
  <p>I've created the above in the <a href="https://www.typescriptlang.org/play?ssl=11&amp;ssc=27&amp;pln=6&amp;pc=1#code/C4TwDgpgBAYgdlAvFAFGAjALigZ2AJwEs4BzAGijACZs4BXAWwCMJ8KwBmbJgex4BsIAQzgBKJAD4oANx6EAJgG4AUKEhQACkPxCGOJJu26IwVjgA88CSuUB6W1AAqAeQAizqAyEBraMAAWhPokEHCshADGUMRQ9MysUDwAZtGmelDAPFD4EAw80hB2Djg8DCaBpFD8hL5QAEq5+RAwhPh4AHIAkmkWWjp6FFQSquDQDXkFLW3AjgDuPOaOUBAAHqZw8vp0cN5wPLNwANoAulLIKCgAdNcr2I7iiFKyCuKr65uo-tjESQkAghQAFbfOC-fBQABCFGul2AILB9QeTzk8igAH56lBaBACvgbElthFgIQeAgmNortccnhsOMmlM8HMFn1dDgJOIAN4AX2UynJ+BQBDoEFEiig9kS3j5FIA5DKKAAGChCkViiWsfA8fDSgVKjL4YWi8UODVaoA" rel="nofollow noreferrer">TS Playground</a>.</p>
  <p>Thank you for looking at this!</p>