title: How can I dynamically generate types for Redux Actions?
body: <p>I'm trying to create actions for Redux that correspond with network requests. So, my goal is to have:</p>
  
  <pre><code>GET_USERS_STARTED
  GET_USERS_COMPLETED
  GET_USERS_ERRORED
  </code></pre>
  
  <p>as possible action types. Currently, I can do that with:</p>
  
  <pre><code>export type reduxActions = typeof GET_USERS_STARTED | typeof GET_USERS_COMPLETED | typeof GET_USERS_ERRORED;
  </code></pre>
  
  <p>but my goal is to use some dynamic programming so I can do something like:</p>
  
  <pre><code>function networkRequestable(str) {
    return [ `${str}_STARTED`, `${str}_COMPLETED`, `${str}_ERRORED`];
  }
  
  export type reduxActions = networkRequestable(GET_USERS)
  </code></pre>
  
  <p>And then components, reducers, etc. could rely on the signature of <code>GET_USERS_STARTED</code>, etc. without writing out types for every API action that might happen.</p>
  
  <p>I've looked at Interfaces and Custom Guard Checks, but I think Interfaces are too "open" while guard checks are only at runtime to coerce into existing types.</p>
  
  <p>I'm not sure if there's a way to do this or if I'm just thinking about TypeScript incorrectly. Thanks for any guidance!</p>