Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File saver is deprecated. How to resolve this issue from SonarQube

Working on filesaver, while running SONAR QUBE it shows " 'fileSaver' is deprecated. use { autoBom: false } as the third argument "

 this.http.get(`getTemplate/${doc.id}`, { responseType: 'blob' }).subscribe(
      (data: any) => {
        fileSaver.saveAs(new Blob([data], { type: this.fileType }), doc.docName)

error :- 'fileSaver' is deprecated. use { autoBom: false } as the third argument

Even if I use autobom:false it still shows the same

Here is the code for autobom

this.http.get(`getDocument/${doc.docId}`, { responseType: 'blob' }).subscribe(
      (data: any) => {
        var blob = new Blob([data], { type: this.fileType });
        fileSaver.saveAs(blob, doc.docName,false);

'saveAs' is deprecated. use { autoBom: false } as the third argumentWhy is this an issue?

'fileSaver' is deprecated. use { autoBom: false } as the third argument Why is this an issue?

like image 748
hanu saikrishna Avatar asked Nov 15 '25 19:11

hanu saikrishna


1 Answers

I had the same issue. I fixed by importing only the function.

For ts

import { saveAs } from 'file-saver';

saveAs(blob, doc.docName);

For js

const { saveAs } = require('file-saver');

I think that this sonar issue is because the browsers do not natively support interface.

like image 111
jhonnyfc Avatar answered Nov 17 '25 10:11

jhonnyfc