Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axios 1.2.0 requires ProgressEvent DOM type #5297

Closed
gzm0 opened this issue Nov 23, 2022 · 7 comments · Fixed by #5308
Closed

Axios 1.2.0 requires ProgressEvent DOM type #5297

gzm0 opened this issue Nov 23, 2022 · 7 comments · Fixed by #5308

Comments

@gzm0
Copy link

gzm0 commented Nov 23, 2022

Describe the bug

Seems like #5227 re-introduced #3219.

When attempting to compile with TypeScript without DOM types, compilation fails:

node_modules/axios/index.d.ts(275,11): error TS2304: Cannot find name 'ProgressEvent'.

To Reproduce

// tsconfig.json
{
  "compilerOptions": {
    "sourceMap": true,
    "esModuleInterop": true,
    "outDir": "dist",
    "strict": true,
    "target": "es2018",
    "module": "commonjs",
    "lib": ["es2018"],
    "forceConsistentCasingInFileNames": true,
    "moduleResolution": "node"
  }
}

Code snippet

import axios from "axios";

axios({
    method: "GET",
    url: "https://example.com",
  });

Expected behavior

Compiles without DOM types.

Axios Version

1.2.0

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

No response

OS

No response

Additional Library Versions

typescript: 4.9.3

Additional context/Screenshots

No response

@badfun
Copy link

badfun commented Nov 29, 2022

Same issue here. Typescript 4.9.3, Axios 1.2.0

@Robert-Rendell
Copy link

I fixed this by using this in my package.json and npm i:

"axios": "~1.0.0",

@hlibcentrica
Copy link

hlibcentrica commented Dec 1, 2022

The only thing that helped, except using DOM types, was downgrading back to Axios v0.27.2

  • Is there a way to emulate this ProgressEvent in the project while we are waiting for a fix?

Edit: added interface ProgressEvent {} to my typings.d.ts

@gzm0
Copy link
Author

gzm0 commented Dec 1, 2022

The only thing that helped, except using DOM types, was downgrading back to Axios v0.27.2

For us, Axios 1.1.3 does not expose this issue so you should be able to at least do the switch to 1.x.

@bradleymackey
Copy link

declare type ProgressEvent = never

@pSnehanshu
Copy link

Thanks, @bradleymackey for the workaround. A fix has been created, but not released yet. Until then, this workaround works.

@riywo
Copy link

riywo commented Dec 12, 2022

Looks like 1.2.1 contains this fix! https://github.com/axios/axios/releases/tag/v1.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants