I have a JavaScript file and want to use it in an React Component. The Script looks following:
function XMLtoJSON() {
....
}
var xml2json = new XMLtoJSON();
And an d.ts File with
interface XMLtoJSON {
...
}
declare var xml2json: XMLtoJSON;
I tried to use import './xml2json.js' and the js-code is included in the generated js file, but the part that creates the variable xml2json is not executed.
I recive following error in the browser console 'xml2json' is undefined
If it should be important, I use typescript and .tsx-files.
The Project was created with create-react-app MyProject --scripts-version=react-scripts-ts