简体   繁体   中英

msSaveOrOpenBlob property doesn't exist on type Navigator angular 13

The property msSaveOrOpenBlob doesn't exist on type Navigator after updating to the angular 13.

I know the Navigator.msSaveOrOpenBlob is being deprecated as per https://developer.mozilla.org/en-US/docs/Web/API/Navigator/msSaveOrOpenBlob#browser_compatibility

I had an angular 12 application, now I am migrating to angular 13 and typescript have been updated to the latest version, but facing the issue of The property msSaveOrOpenBlob doesn't exist on type Navigator

what will be the alternate code for the below

if (window.navigator.msSaveOrOpenBlob) {
            navigator.msSaveOrOpenBlob(blob, filename);
        }
let newVariable: any = window.navigator;
var newBlob = new Blob([res.body], { type: "application/csv" });
if (newVariable && newVariable.msSaveOrOpenBlob) {
    newVariable.msSaveOrOpenBlob(newBlob);
    return;
}

Found some of the references

https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1029 https://github.com/microsoft/TypeScript/issues/45612

Use the declaration merging and declare the types locally in your project work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM