Filesaver.js: Compile with warnings

Created on 27 Sep 2018  路  7Comments  路  Source: eligrey/FileSaver.js

I update to 2.0.0-rc.2 and when I compile my angular project I receive this in console:

WARNING in ./src/app/pages/sidenav/components/info-alteracion/components/list-documents/list-documents.component.ts 80:16-22 "export 'saveAs' was not found in 'file-saver'

My code

import { saveAs } from 'file-saver';
/*...*/
    this._http.getDocumento(this.id, id_doc, id_del).subscribe(
      (result: Blob) => {
        if ((result.type == 'application/pdf') || (result.type == 'text/html')) {
          let fileURL = window.URL.createObjectURL(result);
          window.open(fileURL);
        } else {
          saveAs(result, id_doc + '.zip');
        }
      },
      err => throwError(err)
    );

Any idea of how to fix it? Thanks in advance

help wanted

All 7 comments

That pice of code is irrelevant.
The code that is interesting is how you import the saveAs function in the top of your file

btw, v2 supports saving url's now

saveAs('/asset/doc.pdf', 'doc.pdf')

I update the piece of code. Btw, I import using this :

import { saveAs } from 'file-saver';

You can remove the object destruction

I don't understand your response

this is object destruction: const {foo} = {foo: 1}

mdn Object destructuring

You can remove the object destruction

means you should remove the object destructing and just do

import saveAs from 'file-saver';

Thanks, issue solved!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sangyeol-kim picture sangyeol-kim  路  5Comments

bholyfield picture bholyfield  路  6Comments

profile4vaibhav picture profile4vaibhav  路  5Comments

MFEKN picture MFEKN  路  5Comments

danielbronder picture danielbronder  路  6Comments