Angular2 FileSaver.js
<p>I'm using FileSaver.js with angular 2 and it works pretty well; however, I'm getting a semantic error in my build:</p>

<blockquote>
  <p>error TS2304: Cannot find name 'saveAs'</p>
</blockquote>

<p>I'm using the angular 2 seed and added the library to my project.config like this:</p>

<pre><code>this.NPM_DEPENDENCIES = [
      ...this.NPM_DEPENDENCIES,
{src: 'file-saver/FileSaver.min.js', inject: true},

    ];


this.SYSTEM_CONFIG_DEV.paths['file-saver'] =
        `${this.APP_BASE}node_modules/file-saver/FileSaver`;

    this.SYSTEM_BUILDER_CONFIG.packages['file-saver'] = {
      main: 'FileSaver.js',
      defaultExtension : 'js'
    };
</code></pre>

<p>I can use saveAs in my component:</p>

<pre><code>downloadFile(data: any){

        var blob = new Blob([data], { type: 'text/csv' });

        //saveAs is a function in the FileSaver.js library https://github.com/eligrey/FileSaver.js
        saveAs(blob, "results.csv");
    }
</code></pre>

<p>The problem is that the semantic error causes my build to fail when pushed to my cloud environment. </p>

<p>I've tried adding the typing via:</p>

<pre><code>npm i @types/file-saver
</code></pre>

<p>This allows me to import:</p>

<pre><code>import { saveAs } from 'file-saver';
</code></pre>

<p>However, this gives me the error:</p>

<blockquote>
  <p>h.saveAs is not a function</p>
</blockquote>