Typescript : Trying the addition of two variables but get the concatenation of the two
<p>I have three variable in my Typescript class : </p>

<pre><code>A:number;
B:number;
C:number;
</code></pre>

<p>in another part of the class i try to make the addition of the two variable A and B :</p>

<pre><code>this.C = this.A+this.B; // A =20 and B = 50;
</code></pre>

<p>and I display C in the html template </p>

<pre><code>&lt;span&gt;{{C}}&lt;/span&gt;
</code></pre>

<p>My problem is, instead of getting the addition of the TWO variable <code>(20+50=70)</code> i get the concatenation (2050)!!</p>

<p>Can someone help me please ?</p>

<p><strong>UPDATE</strong> : </p>

<p>Here is the exact code portion that cause problem :</p>

<pre><code>goTo(page:number,type:script) {
    //    
    this.pageFirstLineNumber = page;
    this.pageLastLineNumber = page + this.LINE_OFFSET; //concatenation!!
}
</code></pre>

<p>Notice that pageLastNumber is declared as number type, LINE_OFFSET is olso number type, i have found a solution to this issue but the typescript compiler output an error (forbidden eval): </p>

<pre><code>////
....
this.pageFirstLineNumber = eval(page.toString()); // now It works !!
this.pageLastLineNumber = page + this.LINE_OFFSET; //concatenation!!
</code></pre>

<p><strong>UPDATE</strong></p>

<p>Here is the declaration of the LINE_OFFSET variable : </p>

<pre><code>private _calculateOffset(fontSize: number) {
    let linesDiff = (fontSize * 27) / 14;
    let lines:number = 27 - (linesDiff - 27);
    this.LINE_OFFSET = Math.floor(lines);
    if (fontSize &gt;= 17 &amp;&amp; fontSize &lt;= 20) {
        this.LINE_OFFSET += (Math.floor(fontSize / 3) - 2);
    }
    if (fontSize &gt; 20 &amp;&amp; fontSize &lt;= 23) {
        this.LINE_OFFSET += (Math.floor(fontSize / 2) - 2);
    }
    if (fontSize &gt; 23 &amp;&amp; fontSize &lt;= 25) {
        this.LINE_OFFSET += (Math.floor(fontSize / 2));}
    if (fontSize &gt; 25 &amp;&amp; fontSize &lt;= 27) {
        this.LINE_OFFSET += (Math.floor(fontSize / 2) + 1);
    }
    if (fontSize &gt; 27 &amp;&amp; fontSize &lt;= 30) {
        this.LINE_OFFSET += (Math.floor(fontSize / 2) + 4);
    }
}
</code></pre>