<p dir="auto">For example, a function takes any number of parameters and return the last one.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="function GetLastOne&lt;T&gt;(...rest:any[], last:T)
{
    return last;
}"><pre class="notranslate"><code class="notranslate">function GetLastOne&lt;T&gt;(...rest:any[], last:T)
{
    return last;
}
</code></pre></div>
<p dir="auto">and this: <a href="http://createjs.com/docs/easeljs/classes/Container.html#method_addChild" rel="nofollow">http://createjs.com/docs/easeljs/classes/Container.html#method_addChild</a></p>
<p dir="auto">Extracting this suggestion from this issue:<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="50694125" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/1336" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/1336/hovercard" href="https://github.com/microsoft/TypeScript/issues/1336">#1336</a></p>
<p dir="auto">Currently the variable arguments list supports variable arguments only as the last argument to the function:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function foo(arg1: number, ...arg2: string[]) {
}"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-s1">arg1</span>: <span class="pl-smi">number</span><span class="pl-kos">,</span> ...<span class="pl-s1">arg2</span>: <span class="pl-smi">string</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">This compiles to the following javascript:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function foo(arg1) {
    var arg2 = [];
    for (var _i = 1; _i &lt; arguments.length; _i++) {
        arg2[_i - 1] = arguments[_i];
    }
}"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-s1">arg1</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">var</span> <span class="pl-s1">arg2</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
    <span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">var</span> <span class="pl-s1">_i</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span><span class="pl-kos">;</span> <span class="pl-s1">_i</span> <span class="pl-c1">&lt;</span> <span class="pl-smi">arguments</span><span class="pl-kos">.</span><span class="pl-c1">length</span><span class="pl-kos">;</span> <span class="pl-s1">_i</span><span class="pl-c1">++</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-s1">arg2</span><span class="pl-kos">[</span><span class="pl-s1">_i</span> <span class="pl-c1">-</span> <span class="pl-c1">1</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-smi">arguments</span><span class="pl-kos">[</span><span class="pl-s1">_i</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">However, variable argument functions are limited to appearing only as the last argument and not the first argument. I propose support be added for having a variable argument appear first, followed by one or more fixed arguments:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function subscribe(...events: string[], callback: (message: string) =&gt; void) {
}

// the following would compile
subscribe(message =&gt; alert(message)); // gets all messages
subscribe('errorMessages', message =&gt; alert(message));
subscribe(
  'errorMessages',
  'customMessageTypeFoo123', 
  (message: string) =&gt; {
     alert(message);
  });

// the following would not compile
subscribe(); // supplied parameters do not match any signature of call target
subscribe('a1'); // argument of type 'string' does not match parameter of type '(message: string) =&gt; void'
subscribe('a1', 'a2'); // argument of type 'string' does not match parameter of type '(message: string) =&gt; void'"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">subscribe</span><span class="pl-kos">(</span>...<span class="pl-s1">events</span>: <span class="pl-smi">string</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-s1">callback</span>: <span class="pl-kos">(</span><span class="pl-s1">message</span>: <span class="pl-smi">string</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
<span class="pl-kos">}</span>

<span class="pl-c">// the following would compile</span>
<span class="pl-en">subscribe</span><span class="pl-kos">(</span><span class="pl-s1">message</span> <span class="pl-c1">=&gt;</span> <span class="pl-en">alert</span><span class="pl-kos">(</span><span class="pl-s1">message</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// gets all messages</span>
<span class="pl-en">subscribe</span><span class="pl-kos">(</span><span class="pl-s">'errorMessages'</span><span class="pl-kos">,</span> <span class="pl-s1">message</span> <span class="pl-c1">=&gt;</span> <span class="pl-en">alert</span><span class="pl-kos">(</span><span class="pl-s1">message</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-en">subscribe</span><span class="pl-kos">(</span>
  <span class="pl-s">'errorMessages'</span><span class="pl-kos">,</span>
  <span class="pl-s">'customMessageTypeFoo123'</span><span class="pl-kos">,</span> 
  <span class="pl-kos">(</span><span class="pl-s1">message</span>: <span class="pl-smi">string</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
     <span class="pl-en">alert</span><span class="pl-kos">(</span><span class="pl-s1">message</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-c">// the following would not compile</span>
<span class="pl-en">subscribe</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// supplied parameters do not match any signature of call target</span>
<span class="pl-en">subscribe</span><span class="pl-kos">(</span><span class="pl-s">'a1'</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// argument of type 'string' does not match parameter of type '(message: string) =&gt; void'</span>
<span class="pl-en">subscribe</span><span class="pl-kos">(</span><span class="pl-s">'a1'</span><span class="pl-kos">,</span> <span class="pl-s">'a2'</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// argument of type 'string' does not match parameter of type '(message: string) =&gt; void'</span></pre></div>
<p dir="auto">subscribe compiles to the following JavaScript:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function subscribe() {
  var events= [];
  var callback = arguments[arguments.length - 1];
  for(var _i = 0; _i &lt; arguments.length - 2; _i++) {
    events[_i] = arguments[_i];
  }
}"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">subscribe</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">var</span> <span class="pl-s1">events</span><span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
  <span class="pl-k">var</span> <span class="pl-s1">callback</span> <span class="pl-c1">=</span> <span class="pl-smi">arguments</span><span class="pl-kos">[</span><span class="pl-smi">arguments</span><span class="pl-kos">.</span><span class="pl-c1">length</span> <span class="pl-c1">-</span> <span class="pl-c1">1</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
  <span class="pl-k">for</span><span class="pl-kos">(</span><span class="pl-k">var</span> <span class="pl-s1">_i</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span> <span class="pl-s1">_i</span> <span class="pl-c1">&lt;</span> <span class="pl-smi">arguments</span><span class="pl-kos">.</span><span class="pl-c1">length</span> <span class="pl-c1">-</span> <span class="pl-c1">2</span><span class="pl-kos">;</span> <span class="pl-s1">_i</span><span class="pl-c1">++</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-s1">events</span><span class="pl-kos">[</span><span class="pl-s1">_i</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-smi">arguments</span><span class="pl-kos">[</span><span class="pl-s1">_i</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">notes: it should be impossible for typescript code to call this function with zero arguments when typechecking. If JS or untyped TS code calls it without arguments, callback will be undefined. However, the same is true of fixed arguments at the beginning of the function.</p>
<p dir="auto">edit: used a more realistic/motivating example for the fixed-last/variable-arguments-first function.</p>