title: Angular Property 'offsetWidth' does not exist on type 'Element'
body: <p>new to angular, I am trying to use ScrollTrigger for horizontal scroll.</p>
  <p>It work, but when I serve or build I got the error :
  Property 'offsetWidth' does not exist on type 'Element'.</p>
  <p>This is the code for the gsap :</p>
  <pre><code>gsap.to(sections, {
    xPercent: -100 * (sections.length - 1),
    ease: &quot;none&quot;,
    scrollTrigger: {
      trigger: &quot;.panel-container&quot;,
      pin: true,
      scrub: 1,
      snap: 1 / (sections.length - 1),
      end: () =&gt; &quot;+=&quot; + document.querySelector(&quot;.panel-container&quot;).offsetWidth
    }
  });
  </code></pre>
  <p>Even if I get the error it work, when I console log the &quot;document.query..&quot; I got the good width of the element.</p>
  <p>But the error prevent me to ng build.
  I already did the cast thing, first with :</p>
  <pre><code>let myElem = document.querySelector(&quot;.panel-container&quot;).offsetWidth as HTMLElement;
  </code></pre>
  <p>Or with  before but this don't work, I have the line with red underline with error message :
  Conversion of type 'string' to type 'HTMLElement' may be a mistake because neither type sufficiently overlaps with the other.</p>
  <p>My angular project is 10.0.5.</p>
  <p>Tried the solution in reply :</p>
  <pre><code>(document.querySelector(&quot;.panel-container&quot;) as HTMLElement).offsetWidth;
  </code></pre>
  <p>But got this error on red underline, but nothin in console when I ng serve.</p>
  <blockquote>
  <p>Conversion of type 'Element' to type 'HTMLElement' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Type 'Element' is missing the following properties from type 'HTMLElement': accessKey, accessKeyLabel, autocapitalize, dir, and 105 more.ts(2352)</p>
  </blockquote>