title: How to cast a String variable to a String Literal Type in Typescript
body: <p>In Typescript, suppose I want to call a function with following signature-</p>
  
  <pre><code>function foo(param: "TRUE"|"FALSE"|"NONE")
  </code></pre>
  
  <p>How can I do something like-</p>
  
  <pre><code>var str = runtimeString()
  if(str === "TRUE" | str === "FALSE" | str === "NONE")
      foo(str)
  </code></pre>
  
  <p>Or, the explicit values are the only way-</p>
  
  <pre><code>var str = runtimeString()
  if(str === "TRUE")
      foo("TRUE")
  else if(str === "FALSE" )
      foo("FALSE")
  else if(str === "NONE")
      foo("NONE")
  </code></pre>