Superagent: Using superagent with typescript causes error TS2304: Cannot find name 'Blob' and 'XMLHttpRequest'

Created on 16 Nov 2018  路  5Comments  路  Source: visionmedia/superagent

When I run tsc to compile my code I get the following error. I also installed @types/superagent

node_modules/@types/superagent/index.d.ts:29:29 - error TS2304: Cannot find name 'Blob'.

29 type MultipartValueSingle = Blob | Buffer | fs.ReadStream | string | boolean | number;
                               ~~~~

node_modules/@types/superagent/index.d.ts:116:14 - error TS2304: Cannot find name 'XMLHttpRequest'.

116         xhr: XMLHttpRequest;
                 ~~~~~~~~~~~~~~

Most helpful comment

@SergioFaya Im still having this problem, if it's comfortable for you, could you tell me how did you work arround this?
Thank you in advance.

Edit - Solution

It seems like I found the solution, but not the problem.
My new configuration file just includes compilerOptions.lib.es6 and compilerOptions.lib.dom

"compilerOptions": {
  "lib": [
    "es6",
    "dom"
  ]
}

If anyone has a remote idea of why is this happening, I would be happy to listen to it.

All 5 comments

Please report it to the author of index.d.ts. We don't maintain this file.

Ok, thanks.

@SergioFaya Im still having this problem, if it's comfortable for you, could you tell me how did you work arround this?
Thank you in advance.

Edit - Solution

It seems like I found the solution, but not the problem.
My new configuration file just includes compilerOptions.lib.es6 and compilerOptions.lib.dom

"compilerOptions": {
  "lib": [
    "es6",
    "dom"
  ]
}

If anyone has a remote idea of why is this happening, I would be happy to listen to it.

@SergioFaya Im still having this problem, if it's comfortable for you, could you tell me how did you work arround this?
Thank you in advance.

Edit - Solution

It seems like I found the solution, but not the problem.
My new configuration file just includes compilerOptions.lib.es6 and compilerOptions.lib.dom

"compilerOptions": {
  "lib": [
    "es6",
    "dom"
  ]
}

If anyone has a remote idea of why is this happening, I would be happy to listen to it.

this could be perfect solution of the issue, cause superAgent supports both browser and node. So when you use superAgent with TypeScript, some browser supports need to be added and that means you need to add dom to compilerOptions.lib

comfortable

If I not wrong I manage to solve it by just updating to the latest version. But I can't say for sure because I fixed it long ago

Was this page helpful?
0 / 5 - 0 ratings

Related issues

t3hmrman picture t3hmrman  路  9Comments

tj picture tj  路  4Comments

littlee picture littlee  路  8Comments

littlee picture littlee  路  5Comments

kornelski picture kornelski  路  4Comments