title: How to use "RegExp.exec" in TypeScript?
body: <p>I want to use the method "exec" in RegExp. I write below code to try to do:</p>
  
  <pre><code>let result = &lt;RegExpExecArray&gt;{};
  while (result = expressionCheck.exec(text)) {
      let matchIndex = result.index;
      let t = result[0].length;
      matchRanges.push(new RegRange(matchIndex, t));
  }
  </code></pre>
  
  <p>But it throws error about:</p>
  
  <pre><code>Build:Type 'RegExpExecArray | null' is not assignable to type 'RegExpExecArray'.
  </code></pre>
  
  <p>I try to modify the loop condition to :</p>
  
  <pre><code>while ((result = expressionCheck.exec(text)) != null) {
  </code></pre>
  
  <p>It still doesn't work. So how to write the loop condition for this case?</p>