Note that there are some explanatory texts on larger screens.

plurals
  1. POTypeScript 0.9.5 - ...args: any[] dead in the water? (Looking at Q.d.ts)
    primarykey
    data
    text
    <p>I'm hoping that one of the TypeScript will be able to pitch in here. I'm one of the Definitely Typed contributors and I've been working on fixing up the broken tests related to <a href="https://github.com/borisyankov/DefinitelyTyped/blob/master/q/Q.d.ts" rel="nofollow">Q.d.ts</a>.</p> <p>The following test in <a href="https://github.com/borisyankov/DefinitelyTyped/blob/master/q/Q-tests.ts" rel="nofollow">q-tests.ts</a> worked pre TS 0.9.5:</p> <pre><code>var eventualAdd = Q.promised((a: number, b: number) =&gt; a + b); </code></pre> <p>The <code>promised</code> method definition looks like this:</p> <pre><code>export function promised&lt;T&gt;(callback: (...args: any[]) =&gt; T): (...args: any[]) =&gt; Promise&lt;T&gt;; </code></pre> <p>But now we're on 0.9.5 this test does not compile and fails with this error:</p> <pre><code>error TS2082: Supplied parameters do not match any signature of call target: Call signatures of types '(a: number, b: number) =&gt; number' and '(...args: any[]) =&gt; {}' are incompatible: Call signature expects 0 or fewer parameters. error TS2087: Could not select overload for 'call' expression. </code></pre> <p>I've tried tweaking the test to get a little more insight - for instance by specifying the typing like so:</p> <pre><code>var eventualAdd = Q.promised&lt;number&gt;((a: number, b: number) =&gt; a + b); </code></pre> <p>But I'm not getting much more information - it fails in a similar fashion like this:</p> <pre><code>error TS2082: Supplied parameters do not match any signature of call target: Call signatures of types '(a: number, b: number) =&gt; number' and '(...args: any[]) =&gt; number' are incompatible: Call signature expects 0 or fewer parameters. error TS2087: Could not select overload for 'call' expression. </code></pre> <p>Can anyone provide any insight? I don't see any issues with the way the typing is described. It looks correct but it doesn't work. I seem to remember that with TS 0.9.5 any is now treated as {} by default? Does this blow the <code>...args: any[]</code> callback signature out of the water? I do hope not!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload