question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find name 'ProgressEvent' when compiling TypeScript

See original GitHub issue

Describe the bug

When trying to compile a Firebase function (Node.js / TypeScript) I get an error:

node_modules/axios/index.d.ts:62:38 - error TS2304: Cannot find name 'ProgressEvent'.

62   onUploadProgress?: (progressEvent: ProgressEvent) => void;
                                        ~~~~~~~~~~~~~

node_modules/axios/index.d.ts:63:40 - error TS2304: Cannot find name 'ProgressEvent'.

63   onDownloadProgress?: (progressEvent: ProgressEvent) => void;
                                          ~~~~~~~~~~~~~

To Reproduce

Example of a package.json that fails to compile using npm run build.

{
  "name": "functions",
  "scripts": {
    "lint": "eslint -c .eslintrc.js --ext .ts ./src",
    "lint-fix": "eslint -c .eslintrc.js --fix --ext .ts ./src",
    "build": "tsc",
    "serve": "npm run build && firebase serve --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "firebase": "firebase serve --only functions --port=8080",
    "deploy": "npm run build && npm run lint && firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "main": "lib/index.js",
  "dependencies": {
    "axios": "^0.20.0",
    "firebase-functions": "^3.10.0"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^3.9.1",
    "@typescript-eslint/parser": "^3.9.1",
    "eslint": "^7.7.0",
    "eslint-config-prettier": "^6.11.0",
    "eslint-plugin-import": "^2.22.0",
    "eslint-plugin-prettier": "^3.1.4",
    "prettier": "^2.0.5",
    "typescript": "^3.9.7"
  },
  "private": true,
  "engines": {
    "node": "10"
  }
}

Expected behavior

The Node.js code should compile.

Environment

  • Axios Version: 0.20.0
  • Node.js Version: 10.21.0
  • OS: Ubuntu 20.04

Additional context/Screenshots

None.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:64
  • Comments:32 (4 by maintainers)

github_iconTop GitHub Comments

30reactions
FlorianPfisterercommented, Aug 21, 2020

As a quick fix, you can downgrade the axios version by using the following in your package.json:

"dependencies": {
    "axios": "^0.19.0"
}

Make sure to re-run npm install afterwards.

23reactions
jan-molakcommented, Aug 25, 2020

👋 Hey folks, I’d like to suggest to avoid the dependency on lib dom and instead of using a triple-slash directive replace ProgressEvent with its structural equivalent. This will allow Axios types to transpile correctly on both frontend and pure Node.js projects.

Please see my proposal at #3228.

Thanks, Jan

CC: @Guillaume-Mayer, @bennyn

Read more comments on GitHub >

github_iconTop Results From Across the Web

[object ProgressEvent] with next JS/typescript - Stack Overflow
I'm trying to create simple blog with nextJS/typescript and sanity CMS backend. When I run dev, it successfully compiles but then I get...
Read more >
XMLHttpRequest: progress event - Web APIs - MDN Web Docs
The progress event is fired periodically when a request receives more data. Syntax. Use the event name in methods like addEventListener() , or ......
Read more >
axios - npm
If you compile TypeScript to CJS and you can't use "moduleResolution": "node 16" , you have to enable esModuleInterop . If you use...
Read more >
TypeScript Cheat Sheet - SaltyCrane
TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. This is a list of TypeScript ... See also my TypeScript...
Read more >
Chapter 12. Interacting with servers using HTTP - Angular ...
By default, the response type is any , and the TypeScript compiler won't be able to type-check the properties you access on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found