The function xml2js is currently declared as returning "Element | ElementCompact".
This means I can't assign it the result to a variable of type Element even if I specify {compact: false}.
const x: Element = convert.xml2js('<a></a>', { compact: false});
// Error TS2322 (TS) Type 'Element | ElementCompact' is not assignable to type 'Element'.
Type 'Element' is missing the following properties from type 'Element': assignedSlot, classList, className, clientHeight, and 122 more.
I suggest changing the declaration to something like this:
The function xml2js is currently declared as returning "Element | ElementCompact". This means I can't assign it the result to a variable of type Element even if I specify {compact: false}.
I suggest changing the declaration to something like this:
So that typescript can detect the type when possible.