title: Using @type for declare type of class method in JavaScript
body: <p>When I use <code>@type</code> to declare type of class method in JavaScript with <code>d.ts</code> (see <a href="https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html" rel="nofollow noreferrer">Type Checking JavaScript Files</a>), the parameter types are determined incorrectly, if I use the short form of the method entry. If I use a form with <code>function</code>, everything works correctly.</p>
  <p><em><strong>It's bug, or implemented so intentionally?</strong></em></p>
  <blockquote>
  <p>PS: using an interface for a class with methods defined in it also does not work</p>
  </blockquote>
  <h2 id="common-test.d.ts-1wev">common test.d.ts</h2>
  <pre><code>declare module 'MyTest' {
  
    interface MyTest_FN1 {
      (a: [string, ...Array&lt;string&gt;]): string[]
    }
  
    interface TestFN {
      (name: string, ...args: string[]): string[]
    }
  }
  </code></pre>
  <h2 id="it-doesnt-work-kdll">It doesn't work:</h2>
  <pre class="lang-js prettyprint-override"><code>/// &lt;reference path=&quot;./test.d.ts&quot;/&gt;
  // @ts-check
  
  /** test class */
  class MyTest {
  
    /** @type {import('MyTest').MyTest_FN1} */
    fn1(args) {
      return testFn(...args)
    }
  
  }
  
  /** @type {import('MyTest').TestFN} */
  function testFn(name, ...args) {
    return [name, ...args]
  }
  </code></pre>
  <pre class="lang-sh prettyprint-override"><code>npx tsc --allowJs --checkJs --noEmit ./test.js
  &gt; test.js:9:19 - error TS2556: A spread argument must either have a tuple type or be passed 
  </code></pre>
  <p><a href="https://i.stack.imgur.com/1fG8Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1fG8Y.png" alt="enter image description here" /></a></p>
  <h2 id="if-you-add-implements-the-problem-remains-2qxx">If you add @implements, the problem remains:</h2>
  <pre><code>  interface MyTestCLS {
     fn1: MyTest_FN1
    }
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>/** @typedef {import('MyTest').MyTestCLS} IMyTest */
  /** @implements {IMyTest} */
  class MyTest {
  
    /** @type {import('MyTest').MyTest_FN1} */
    fn1(args) {
      // args hav a type??
      return testFn(...args)
    }
  
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/SEJEG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SEJEG.png" alt="enter image description here" /></a></p>
  <h2 id="it-works-snhj">It works:</h2>
  <pre class="lang-js prettyprint-override"><code>/// &lt;reference path=&quot;./test.d.ts&quot;/&gt;
  // @ts-check
  
  /** test class */
  class MyTest {
  
    /** @type {import('MyTest').MyTest_FN1} */
    fn1 = function test(args) {
      // args have a type??
      return testFn(...args)
    }
  
  }
  
  /** @type {import('MyTest').TestFN} */
  function testFn(name, ...args) {
    return [name, ...args]
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/KfSAr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KfSAr.png" alt="enter image description here" /></a></p>