title: 'ResizeObserver' only refers to a type, but is being used as a value here
body: <p>I am getting the error: <code>'ResizeObserver' only refers to a type, but is being used as a value here</code> when attempting to use ResizeObserver in React with TypeScript.</p>
  
  <p>I have the following interface defined as TypeScript does not include definitions:</p>
  
  <pre><code>interface ResizeObserver {
      observe(target: Element): void;
      unobserve(target: Element): void;
      disconnect(): void;
  }
  </code></pre>
  
  <p>And I am using it in the following component:</p>
  
  <pre><code>const useWidth = () =&gt; {
  
      const ref = useRef&lt;HTMLObjectElement&gt;(null);
  
      const [width, setWidth] = useState(0);
  
      useLayoutEffect(() =&gt; {
  
          var resizeObserver = new ResizeObserver(() =&gt; console.log("blah blah blah"))
          resizeObserver.observe(ref.current)
  
          return () =&gt; resizeObserver.disconnect()
  
      }, [ref.current])
  
      return [ref, width];
  }
  </code></pre>