title: How to getElementsByclassName in TypeScript?
body: <p>I'm trying to get the elements by class name from the DOM in typescript. It seems pretty straight forward what I'm doing here but the console shows an error.</p>
  
  <pre><code>function showSlides() {
     var i;
     var slides = &lt;HTMLElement[]&lt;any&gt;document.getElementsByClassName('slide');
  
     for (i = 0; i &lt; slides.length; i++) {
       slides[i].style.display = "none";
     }
  }
  </code></pre>
  
  <p>The expected result should be an array with 3 items and it should change the display style to none, but the actual result is a JS error: <code>Uncaught TypeError: Cannot read property 'style' of undefined.</code></p>