Closed tonysamperi closed 1 year ago
I just saw there's a PR pending: #20
hi, Was wondering how to resolve the typings issue . I install the xhr2 in a typescript project. It install , but on the import im getting :
Could not find a declaration file for module 'xhr2'. '/Users/myoung/projects/qatest/node_modules/xhr2/lib/xhr2.js' implicitly has an 'any' type.
Try npm i --save-dev @types/xhr2
if it exists or add a new declaration (.d.ts) file containing declare module 'xhr2';
Thanks for any help in advance
@mathiskeeper you create a typing file in your project and add it to your tsconfig! This is how I think I solved it...
@tonysamperi So i added a index.d.ts to the xhr2 node module ,then added it to the tsconfig json with tag. : "typeRoots": [ "./typings", "./node_modules/@types/" ] }
after that for TS files only. I added the import with global.XMLHttpRequest = require('xhr2').XMLHttpRequest and that allowed it to work
@mathiskeeper well that's not exactly the clean way to do what I said, but if it works... Cheers!
Hello,
is there any chance to have typings? I could lend a hand to achieve this