title: How to type cast, from "string" which is originally number to number
body: <pre><code> //I am working on this assignment
  objToSendServer.input1 = obj.input1
  
  //type definitions are:
  
  class obj {
      input1: number;
  }
  
  class objToSendServer{
      input1: number
  }
  
  // if I do this assignment that value of obj.input1 is "1"
  // which cause of problem on server side 
  // which is web api odata, patch method that expects type of int
  objToSendServer.input1 = obj.input1;  
  
  // if I try cast as below, error message is:
  //Argument of type 'number' is not assingable of parameter of type 'string'
  objToSendServer.input1 = parseFloat(obj.input1); 
  
  //My work around is:
  objToSendServer.input1 = parseFloat(obj.input1.toString());
  </code></pre>
  
  <p>I suppose that type cast would be done automatically which is not case here.</p>
  
  <p>So my question is there better approach to this type of assignment </p>
  
  <p>Also if obj.input1 is null this workaround fails.</p>
  
  <pre><code>TypeError: Cannot read property 'toString' of null
  </code></pre>
  
  <p>Then I should check if <code>obj.input1</code> is null or not</p>
  
  <p>Note: I edited the title which was <code>Is there "automatic" type cast in typescript</code> to express issue more clear</p>