title: How to use fetch in TypeScript
body: <p>I am using <a href="https://developer.mozilla.org/en/docs/Web/API/Fetch_API" rel="noreferrer">window.fetch</a> in Typescript, but I cannot cast the response directly to my custom type:</p>
  
  <p>I am hacking my way around this by casting the Promise result to an intermediate 'any' variable. </p>
  
  <p>What would be the correct method to do this?</p>
  
  <pre><code>import { Actor } from './models/actor';
  
  fetch(`http://swapi.co/api/people/1/`)
        .then(res =&gt; res.json())
        .then(res =&gt; {
            // this is not allowed
            // let a:Actor = &lt;Actor&gt;res;
  
            // I use an intermediate variable a to get around this...
            let a:any = res; 
            let b:Actor = &lt;Actor&gt;a;
        })
  </code></pre>