Skip to content

Instantly share code, notes, and snippets.

@guidani
Created July 6, 2021 12:15
Show Gist options
  • Save guidani/973dd6325bf941b74b40caf928718888 to your computer and use it in GitHub Desktop.
Save guidani/973dd6325bf941b74b40caf928718888 to your computer and use it in GitHub Desktop.
erro
class Calcula{
private _media14: number;
private _mediaDia: number;
constructor(media14, mediaDia){
this.setMedia14(media14);
this.setMediaDia(mediaDia);
}
set setMedia14(valor:number){
this._media14 = valor;
}
get getMedia14(): number {
return this._media14;
}
set setMediaDia(valor:number){
this._mediaDia = valor;
}
get getMediaDia(): number {
return this._mediaDia;
}
}
@guidani
Copy link
Author

guidani commented Jul 6, 2021

erro acontecendo:

app.ts:17:10 - error TS2349: This expression is not callable.
Type 'Number' has no call signatures.

17 this.setMedia14(media14);
~~~~~~~~~~

app.ts:18:10 - error TS2349: This expression is not callable.
Type 'Number' has no call signatures.

18 this.setMediaDia(mediaDia);

@guidani
Copy link
Author

guidani commented Jul 6, 2021

class Calcula{
  private _media14: number;
  private _mediaDia: number;

  constructor(media14, mediaDia){
    this.setMedia14(media14);
    this.setMediaDia(mediaDia);
  }

  set setMedia14(valor){
    this._media14 = valor;
  }

  get getMedia14() {
    return this._media14;
  }

  set setMediaDia(valor){
    this._mediaDia = valor;
  }

  get getMediaDia() {
    return this._mediaDia;
  }
}

@guidani
Copy link
Author

guidani commented Jul 6, 2021

Paro de ocorrer os erros após retirar os retornos, mas não sei se isso é correto.

@guidani
Copy link
Author

guidani commented Jul 6, 2021

outro erro ao chamar uma função

  calculaVariacaoPercentual(){
    // (VF / VI - 1) x100
    let resultado: number = ((this.getMedia14 / this.getMediaDia)-1)*100
    return resultado
  }

this.setMedia14(media14);
^

TypeError: this.setMedia14 is not a function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment