title: TypeScript: transform one interface to another
body: <p>imagine I have two interfaces:</p>
  
  <pre><code>interface A {
    foo: boolean,
    bar: string,
    baz: string
  }
  
  interface B {
    foo: number,
    bar: string,
    baz: string
  }
  </code></pre>
  
  <p>now I have an object that implements interface <code>A</code> but I need to pass it to a function that expects interface <code>B</code>. Of course I can do:</p>
  
  <pre><code>const another_object: B = {
    foo: original_object.foo? 1 : 0,
    bar: original_object.bar,
    baz: original_object.baz
  }
  </code></pre>
  
  <p>but if A and B contain many fields this notation would be inconvenient.
  Is there any better way to do this in TypeScript?</p>