title: Augment a Type declaration from a library
body: <p>I have imported a library <code>mycoollib</code> which resides in <code>node_modules</code> and has the following folder and file structure</p>
  
  <pre><code>node_modules
     - mycoollib
        - src
            mycoollogic.js
        - types
            index.d.ts
  </code></pre>
  
  <p>The <code>index.d.ts</code>, which contains the type definitions of <code>mycoollib</code>, is this</p>
  
  <pre><code>/// &lt;reference types="node" /&gt;
  
  export type MyCoolType = {
    func1: () =&gt; void
    func2: () =&gt; void
  }
  </code></pre>
  
  <p>In my application I need to augment <code>MyCoolType</code> type definition, adding for instance a third function. So I create <code>my-cool-type-augmentation.d.ts</code> file in my <code>src</code> folder like this</p>
  
  <pre><code>declare namespace mycoollib {
      export type MyCoolType = {
        augmentedFunction: () =&gt; void
      }
  }
  </code></pre>
  
  <p>but this solution seems not to work, since the compiler signals an issue when I try to use <code>augmentedFunction</code> on objects of type <code>MyCoolType</code>.</p>
  
  <p>I have tried also using the module declaration, like this</p>
  
  <pre><code>declare module "mycoollib" {
      export type MyCoolType = {
        augmentedFunction: () =&gt; void
      }
  }
  </code></pre>
  
  <p>but in this case the compiler signals the fact that there is a <strong><em>Duplicate identifier 'MyCoolType'</em></strong> error in <code>index.d.ts</code> and in <code>my-cool-type-augmentation.d.ts</code>. This solution works for me in other cases where I have to augment <strong>interfaces</strong>, but does not seem to work with <strong>types</strong>.</p>