Skip to content

Conversation

@remcohaszing
Copy link
Contributor

The ProgressEvent type comes from the DOM lib. This is typically unwanted when using axios in a NodeJS environment.

Fixes #3219

The `ProgressEvent` type comes from the `DOM` lib. This is typically unwanted
when using axios in a NodeJS environment.
@chinesedfan
Copy link
Contributor

@jasonsaayman Among related PRs, I prefer this one, which simply reverts the type to any. And users can assert the type by themselves.

Similar debates are for method/headers(#2191/#2647). axios tries to provide more detailed enums, then it will prevent users to use other values. Unless all possible values are covered. But those values can be customized.

@Guillaume-Mayer
Copy link

I think @chinesedfan is right, simpler is better sometimes.
Out of curiosity, what is the matter with importing the DOM lib in a node environment? Since it's just typing.

@remcohaszing
Copy link
Contributor Author

@Guillaume-Mayer

Out of curiosity, what is the matter with importing the DOM lib in a node environment? Since it's just typing.

Although these types currently don’t conflict, they might in the future. For a practical example, the types of dom and webworker do conflict, so they can’t be combined within the same project.

TypeScript should help by providing type information. If you’re working on a TypeScript project and somehow one types document.createElement('') in a file, one would expect TypeScript to fail over this.

Also a project that claims to work in a Node environment, shouldn’ require the user to specify they’re using a DOM environment, which is the current situation with Axios.

@jasonsaayman
Copy link
Member

@chinesedfan I like this solution most too, do you think we should add this one into 0.20.1? I am happy to merge it and close the other PR's

@chinesedfan
Copy link
Contributor

@jasonsaayman Sure. Friendly remind that breaking changes should be released in 0.21, instead of 0.20.1. To make things simple, we can release this PR in 0.21 together, though it looks like not breaking.

@remcohaszing
Copy link
Contributor Author

This is non breaking.

Copy link
Member

@jasonsaayman jasonsaayman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@dfee
Copy link

dfee commented Oct 11, 2020

While we wait for this fix to get published, create a typings.d.ts with the following:

/**
 * Fix for axios while we wait for ^0.2.1 to be published
 * merge: https://github.com/axios/axios/commit/b7e954eba3911874575ed241ec2ec38ff8af21bb
 * issue: https://github.com/axios/axios/issues/3219
 */
interface ProgressEvent {}

mbargiel pushed a commit to mbargiel/axios that referenced this pull request Jan 27, 2022
The `ProgressEvent` type comes from the `DOM` lib. This is typically unwanted
when using axios in a NodeJS environment.

Co-authored-by: Jay <[email protected]>
@karlhorky
Copy link
Contributor

karlhorky commented Jul 20, 2022

Rather than changing this to any, why not copy the ProgressEvent types from lib.dom.d.ts into the Axios types?

cc @jasonsaayman

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 this pull request may close these issues.

Cannot find name 'ProgressEvent' when compiling TypeScript

6 participants