title: How to cast object to another type and remove unneeded fields in TypeScript?
body: <p>Suppose I have the following code:</p>
  
  <pre><code>interface A {
      a: number;
  }
  
  interface B extends A {
      b: number;
  }
  
  const b: B = {a: 1, b: 5};
  const a: A = b as A;
  </code></pre>
  
  <p>Now the variable <code>a</code> has type <code>A</code>, but it still contains <code>b</code> inside of it. Sometimes it is undesirable - I'd like to be sure that, if I have a variable of type <code>A</code>, it has the exact fields of type <code>A</code>. I was wondering, whether TypeScript has some kind of a "hard cast" which would remove any unneeded fields when converting between types.</p>