Currently, I am working on a widget for a website that is already utilizing jQuery and I am using TypeScript. The goal is to embed my output into the host website while taking advantage of the existing jQuery library loaded by the host site.
In order to replicate the production environment, I have included references to the host website by including link
and script
tags in the header section of my HTML wrapper development code.
My initial approach to using jQuery in TypeScript was to install @types/jquery
and then import it using import $ from 'jquery';
. However, this method failed during compilation with the error message:
Module not found: Error: Can't resolve 'jquery' [...]
I am seeking guidance on how to inform TypeScript that jQuery is already available within my application so that it can utilize window.jQuery
with type definitions.