title: Augment TypeScript definition class for a third party module
body: <p>I'm trying to add a custom assertion to <a href="https://node-tap.org" rel="nofollow noreferrer"><code>tap</code></a> using the <a href="https://node-tap.org/docs/api/advanced/#taddassertname-length-fn" rel="nofollow noreferrer"><code>addAssert</code></a> API, and I'm struggling to augment the <a href="https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/tap/index.d.ts" rel="nofollow noreferrer">type definitions for the library</a> to add a new custom assertion.</p>
  <pre class="lang-js prettyprint-override"><code>// typings/custom-tap.d.ts
  
  import 'tap'
  
  declare module 'tap' {
      export namespace Tap {
          export interface Test {
              toDoThisNewThing(name: string, cb?: (t: Test) =&gt; Promise&lt;void&gt; | void): Promise&lt;void&gt;;
          }
      }
  }
  </code></pre>
  <p>I've also added this to my TypeScript configuration in <code>tsconfig.json</code> –</p>
  <pre class="lang-json prettyprint-override"><code>&quot;typeRoots&quot;: [
      &quot;./typings&quot;,
      &quot;node_modules/@types/&quot;
  ]
  </code></pre>
  <p>Here's how I am using it –</p>
  <pre class="lang-js prettyprint-override"><code>import tap from 'tap'
  
  t.Test.prototype.addAssert('toDoThisNewThing', 1, function (str, message, extra) {
      return this.ok(true, message, extra)
  })
  
  void tap.test('test stuff', (t) =&gt; {
    t.plan(1)
    t.toDoThisNewThing(42)
    t.end()
  })
  
  </code></pre>
  <p>However, when using the custom assertion, I get the error –</p>
  <pre><code>Property 'toDoThisNewThing' does not exist on type 'Test'. ts(2339)
  </code></pre>