title: TypeScript - returning 2 different interface from a function
body: <p>I'm wondering how can I returning 2 types of object according their interface.</p>
  <p>Into the code below, the declared return of my function</p>
  <pre><code>: Promise&lt;newEventInt | newWalletInt&gt;
  </code></pre>
  <p>make both value that I return underlined</p>
  <pre><code>return {
          currentEvent, 
          wallet
      }
  </code></pre>
  <p>the error message for currentEvent, is that one</p>
  <pre><code>Type 'newEventInt' is not assignable to type 'string | number | boolean | Date | undefined'.
    Type 'newEventInt' is not assignable to type 'string'.ts(2322)
  </code></pre>
  <p>If I take off the declared return, it is working. But I would like to give my code more protection.</p>
  <p>thanks in advance,
  Paul</p>
  <pre><code>    private async isEventOwnedByUser(userId: number, eventId: number): Promise&lt;newEventInt | newWalletInt&gt; {
          // get event + handling error
          const currentEvent: newEventInt = await this.event.findOne(eventId)            
          if (!currentEvent) throw new Error(`This event does not exist`);
  
          //  get user's wallet + handling error
          const wallet: newWalletInt = await this.wallet.getOneWalletByUserId(currentEvent.wallet_id, userId)   
          if (!wallet) throw new Error('This event does not exist')
  
          return {
              currentEvent, 
              wallet
          }
      }
  </code></pre>
  <p>the newEventInt interface</p>
  <pre><code>export interface newEventInt {
      [key: string]: number | string | Date;
  
      type: string,
      date: Date,
      quantity: number,
      total_amount: number,
      unit_price: number,
      fees: number,
      note: string,
      platform_sending: string,
      platform_receiving: string,
      currency_asset: string,
      currency_counterparty: string,
      currency_fees: number,
      wallet_id: number,
      ref_usd_amount: number,
      ref_usd_fees: number,
      created_at: Date
  }
  </code></pre>