Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After update typescript ^3.7.2 to latest "typescript": "^4.4.4" - error TS2339: Property 'msSaveOrOpenBlob' does not exist on type 'Navigator'

I have used this msSaveOrOpenBlob method . its was working properly but after update typescript into latest version I am getting multiple error there is two error .

window.navigator.msSaveOrOpenBlob(data, filename);

error TS2322: Type 'Promise<>' is not assignable to type 'IPromise<>'.

What is the fix of that .

like image 625
amethianil Avatar asked Sep 14 '25 10:09

amethianil


1 Answers

@Heretic Monkey answer is correct, but if you just want to get around the issue - since you are using TypeScript - you can just cast it to type any before calling msSaveOrOpenBlob.

(window.navigator as any).msSaveOrOpenBlob(data, filename);

Also, you should make sure the navigator object does have the method in the first place, so:

const nav = (window.navigator as any);
if (nav.msSaveOrOpenBlob) {
  nav.msSaveOrOpenBlob(data, filename);
}
like image 131
MMalke Avatar answered Sep 16 '25 00:09

MMalke