title: In TypeScript, How to cast boolean to number, like 0 or 1
body: <p>As we know, the type cast is called assertion type in TypeScript. And the following code section:</p>
  
  <pre><code>// the variable will change to true at onetime
  let isPlay: boolean = false;
  let actions: string[] = ['stop', 'play'];
  let action: string = actions[&lt;number&gt; isPlay];
  </code></pre>
  
  <p>On compiling, it go wrong</p>
  
  <pre><code>Error:(56, 35) TS2352: Neither type 'boolean' nor type 'number' is assignable to the other.
  </code></pre>
  
  <p>Then I try to use the <code>any</code> type:</p>
  
  <pre><code>let action: string = actions[&lt;number&gt; &lt;any&gt; isPlay];
  </code></pre>
  
  <p>Also go wrong. How can I rewrite those code.</p>