title: How to preserve Typescript return types when calling Promise.all?
body: <p>I have the following code where i have two functions which return objects of two different types (InterfaceA and InterfaceB)</p>
  
  <p>Now, when i call Promise.all on them, i cant define the type of promises variable so i have to go with any.</p>
  
  <pre class="lang-ts prettyprint-override"><code>  interface InterfaceA {
      value: string;
    }
  
    interface InterfaceB {
      value: number;
    }
  
    const returnA = (): Promise&lt;InterfaceA&gt; =&gt; {
      const obj: InterfaceA = {
        value: 'a'
      };
      return Promise.resolve(obj);
    };
  
    const returnB = (): Promise&lt;InterfaceB&gt; =&gt; {
      const obj: InterfaceB = {
        value: 1
      };
      return Promise.resolve(obj);
    };
  
    const promises: any = [returnA(), returnB()];
    const res = await Promise.all(promises);
  
    console.log(res)
    const objA: InterfaceA = res[0];
  </code></pre>
  
  <p>The problem is that once i get the response of Promise.all, and try to define the types of the responses, i get the following errors:</p>
  
  <pre><code>Type '{}' is not assignable to type 'InterfaceA'.
    Property 'value' is missing in type '{}'. (2322)
  Type '{}' is not assignable to type 'InterfaceA'. (2322)
  </code></pre>
  
  <p>I am not exactly sure how to deal with this and what i can do to preserve the type of the objects that i get in the response of Promise.all?</p>
  
  <p>Thanks!</p>