Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.9K
Visualizações
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 .

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

It's my first development in angular more specific in the 12 version, and I created a method in a component that does a download a xlsx file, in Chrome its work but in IE it doesn't work, I find that adding this line window.navigator.msSaveOrOpenBlob(data, filename); Explorer can download file, but in VSC mark error and it is

Property 'msSaveOrOpenBlob' does not exist on type 'Navigator'

and I change the module and lib in tsconfig.json,

"module": "es2020",
"lib": [
    "es2020",
    "dom"
]

to:

"module": "es2015",
"lib": [
    "es2015",
    "dom"
]

In the code window.navigator.msSaveOrOpenBlob VSC mark the same

Property 'msSaveOrOpenBlob'....'

but when I execute ng serve its work and download a xlsx file in IE and Chrome.

over 4 years ago · Santiago Trujillo Relatório

0

msSaveOrOpenBlob was a proprietary addition to the Navigator object, added by Microsoft for Internet Explorer. Since Microsoft is phasing out support for Internet Explorer, it has removed support for many of the non-standard additions made to the lib.dom.d.ts and lib.es*.d.ts files that ship with TypeScript. See this GitHub issue about the changes to the DOM.d.ts file.

As indicated in this GitHub issue on the subject, you will have to use declaration merging to add these types to Navigator yourself.

over 4 years ago · Santiago Trujillo Relatório

0

@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);
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda