Reputation: 153
If I have a global variable var x
in my main.js file, which i'd like to be accessible in a typescript file which is bundled by webpack into the same build/bundle.js, how would i go about this? I cannot access it directly as i assumed i might (them being in the same bundle at the end). I have read of export/import/require but cannot find how to apply this in the context of a webpack bundle.
Upvotes: 3
Views: 4874
Reputation: 1326
You may need to declare the variable in your typescript file so the compiler knows its exists:
declare var x: any;
Upvotes: 4