Currently, I am loading a JS library in the traditional way (using loadScript, <script>
in DOM, etc.), and I have the type definitions available. However, I am struggling to inform Typescript that window.myLibrary
is the constructor for my library and should match the existing type.
If only there was a way to import both the dependency and type definitions simultaneously...
import { MyLibrary } from "myLibrary";
[..]
new MyLibrary("#div", {});
This approach is too modern for my current setup. All I want to do is import the type definitions using Webpack and link them to a window['myLibrary']
variable while still being able to leverage the benefits of Typescript's typing system.