title: How to check if string in type
body: <p>I have the type:</p>
  
  <pre><code>export type PermissionType = 'creator' | 'editor' | 'viewer' 
  </code></pre>
  
  <p>At run time, how to check if a variable userInput is actually one the type above</p>
  
  <pre><code>let userInput = 'foo' //
  isOfTypePermission(userInput)  // should return false or throw an error
  
  let userInput2 = 'creator'
  isOfTypePermission(userInput2) // should return true
  </code></pre>
  
  <p>In other word, how to get the type <strong>PermissionType</strong> compiled into a javascript array so that I can just do <strong>indexOf(userInput) > -1</strong> </p>