Leonidas-from-XIV / node-xml2js

XML to JavaScript object converter.
MIT License
4.84k stars 598 forks source link

Unable to use library in type script react #612

Open bilalmohib opened 3 years ago

bilalmohib commented 3 years ago

Hello Sir Greetings.I want to discuss that I am unable to use the library in typescript React js.  Sir Overall Your library is amazing actually I wanted to parse and fetch XML data and use as array.In JSx the below code works fine.  let parser = new xml2js.Parser(); parser.parseString( `

Test
    <from>Test1</from>
    <heading>Test email</heading>
    <body>Email regards to xml data parsing in React</body>
    </email>`,
  function (error:string,result:string) {
    console.log(result);
  }
);

In the React use Effect and gives the expected output but in typescript file the error is in this line  let parser = new xml2js.Parser();It says Property 'Parser' does not exist on type 'typeof Parser'.Sir can you please help me about the issue.Thanks.  Respectfully yoursMuhammad Bilal