Error in VSCODE console

Asked

Viewed 161 times

0

I have this mistake in VSCODE.

ERROR in src/app/paginas/arquivo/arquivo-form/arquivo-form.component.ts(93,20): error TS2339: Property 'total' does not exist on type 'HttpEvent<{}>'.

Property 'total' does not exist on type 'HttpSentEvent'.
src/app/paginas/arquivo/arquivo-form/arquivo-form.component.ts(93,34): error TS2339: Property 'loaded' does not exist on type 'HttpEvent<{}>'.

Property 'loaded' does not exist on type 'HttpSentEvent'.
src/app/paginas/arquivo/arquivo-form/arquivo-form.component.ts(99,38): error TS2339: Property 'partialText' does not exist on type 'HttpEvent<{}>'.

Property 'partialText' does not exist on type 'HttpProgressEvent'.

But no error occurs in the console when running.

this.arquivoService.salvarArquivo(this.currentFileUpload, this.arquivoSalvar).map(res => res).
      subscribe(event => {
        console.log(event);
        var tipoRetorno : boolean = false;
        if (event.type === HttpEventType.UploadProgress) {
          this.progress.percentage = Math.round(100 * event.loaded / event.total);
        } else if (event instanceof HttpResponse) {
          console.log('File is completely uploaded!');
        }
        if (event.type == 1){
          if(event.total > event.loaded){
            this.openSnackBar("Tamanho do Arquivo maior que o permitido !", tipoRetorno);
          }
        } else {
          if (event.type == 3){
            console.log(event);
            var array = String(event.partialText).split(",");
            var mensagem = String(array[4].replace('"', '').replace('"', '').replace('"', '').replace('"', '')).split(":");
            if(mensagem[1] != "ERRO"){
              tipoRetorno = true;
            }
            var mensagem = String(array[0].replace('"', '').replace('"', '').replace('"', '').replace('"', '')).split(":");
            this.openSnackBar(mensagem[1], tipoRetorno);
            if(mensagem[1] != "ERRO"){
              this.voltar();
            }
          }
        }
      }
    )

inserir a descrição da imagem aqui

Debugging through the browser console, it returns these variables, so I built the code. How can I fix so that VSCODE does not show the error ?

  • Young man I will not answer you by copying and pasting from Stackoverflow in English, but here is a list of questions and answers giant https://www.google.com/search?q=qTS2339:+Property+site:stackoverflow.com&newwindow=1&sa=X&ved=0ahUKEwjr1bvji7LaAhXIf5AKHeDFCwEQrQIITCgEMAI hope you help

  • You have to map the event to the property you want.

  • Thanks @hugocsl. As much as I have several indications on the web, I could not understand or resolve, so I asked for a help on the forum.

  • Thanks @Eduardovargas, but I also didn’t understand what you meant.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.