title: typescript - assigning types to an exported variable of multiple types
body: <p>I'm using nrgx/store and following the example app I'm using classes to strongly type my actions like</p>
  
  <pre><code>export const ActionTypes ={
      SET_ACTIVE_USER: type('[UserState] Set Active User'),
      SET_USERLIST: type('[UserState] Set Userlist')
  };
  
  export class SetActiveUserAction implements Action {
      type = ActionTypes.SET_ACTIVE_USER;
      constructor(public payload:User){}
  }
  
  export class SetUserlistAction implements Action {
      type = ActionTypes.SET_USERLIST;
      constructor(public payload:User[]){}
  }
  
  export type Actions
      = SetActiveUserAction
      | SetUserlistAction
  </code></pre>
  
  <p>I'm having now a type problem in my reducer. Since the exported Actions can be of type User or User[], it doesn't let me assign userlist:User[] to it (i want to use array methods like forEach) </p>
  
  <pre><code>export function reducer(state = INITIAL_STATE, action: userAction.Actions): State {
  
      switch (action.type) {
          case userAction.ActionTypes.SET_USERLIST: {
  
              let userlist:User[] = action.payload &lt;-------Type Issue
  
              return tassign(state, { userlist: action.payload })
          }
  
          default: {
              return state
          }
      }
  }
  </code></pre>