admin管理员组文章数量:1278823
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
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);
}
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/en-US/docs/Web/API/Navigator/msSaveOrOpenBlob#browser_patibility
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);
}
Share
Improve this question
asked Nov 15, 2021 at 7:28
San JaisySan Jaisy
17.1k43 gold badges205 silver badges346 bronze badges
2
- Angular 13 does not support Internet Explorer. Why don't you just drop the code? Even if you pile it, the condition will never be true – Christian Vincenzo Traina Commented Mar 28, 2022 at 10:07
- @ChristianVincenzoTraina I was using this for Edge at one point. I think Edge changed to Chromium at some point; would that have made this useless also for Edge? – indigo Commented Aug 31, 2022 at 19:28
3 Answers
Reset to default 6let 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./microsoft/TypeScript-DOM-lib-generator/issues/1029 https://github./microsoft/TypeScript/issues/45612
Use the declaration merging and declare the types locally in your project work.
Declare below code in main.ts
declare global{
interface Navigator {
msSaveOrOpenBlob?: (blob: any, defaultName?: string) => boolean
}
}
本文标签: javascriptmsSaveOrOpenBlob property doesn39t exist on type Navigator angular 13Stack Overflow
版权声明:本文标题:javascript - msSaveOrOpenBlob property doesn't exist on type Navigator angular 13 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741256383a2366753.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论