title: How can I check if a string belongs to a type in TypeScript?
body: <p>The web audio API has its own types, one of them is BiquadFilterType</p>
  
  <pre><code>type BiquadFilterType = "lowpass" | "highpass" | "bandpass" | "lowshelf" | "highshelf" | "peaking" | "notch" | "allpass"
  </code></pre>
  
  <p>I'm using a  to let the user select which of the types he or she is going to use. So I made a function which receives a string (from the selector) and sets the biquadfilter.type to the received value so I had to give it a signature like</p>
  
  <pre><code>setValue(value: BiquadFilterType) ...
  </code></pre>
  
  <p>But when I try to call my function where the selector is ts complains that I'm giving the function a string whilst it was expecting a BiquadFilterType. Is there any way of checking (inside my function) the type (I've tried typeof and instanceof but none seem to make sense for TS) of the received argument so that TS knows that I'm using it correctly?</p>