Typescript, toFixed. Type 'string' is not assignable to type 'number'
<pre><code>       distanceX = ((this.frontclickedX  - originX) / originX).toFixed(2);
       distanceY = (-(this.frontclickedY - originY) / originY).toFixed(2);
       let distanceZ: number = (-(this.frontclickedY - originY) / originY).toFixed(2);
</code></pre>

<p>my browser throws an error when I calculated distanceZ:</p>

<pre><code>Type 'string' is not assignable to type 'number'.
</code></pre>

<p>the first two lines work perfectly, but the third doesn't really work.
As you can see it is even exact the same calculation as distanceY. I tried to parseFloat() it first. But then it starts to complain that I can only parse a string to a float, and that I didn't provide one.</p>

<p>I'm quite confused at the moment, so some help or a solution would be much appreciated!</p>

<p>Thanks in advance!</p>

<p>Edit: I tried to simplify my code.
Made the distances private and added setters and getters.</p>

<pre><code>private _distanceX: number;
private _distanceY: number;
private _distanceZ: number;

  get distanceZ(): number {
    return this._distanceZ;
}
set distanceZ(value: number) {
    this._distanceZ = value;
} ...
calculateBadgeDistance(): void{
        this.distanceX = (5.001).toFixed(2);
        this.distanceY = (5.001).toFixed(2);
        this.distanceZ = (5.001).toFixed(2);
}
</code></pre>

<p>Now I got the error on all 3 lines.</p>