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
Runtime aspect of HttpStatusCode
missing from JavaScript files
#5126
Comments
Closed
I can confirm this, happens to us too and keeps us from being able to drop our dependency on https://github.com/jrylan/status-code-enum |
Same here. I ended up just copying over the enum values from axios |
same here |
same for me |
same here, but better |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Apologies in advance if I've got the wrong end of the stick, but I think the recent PR adding
HttpStatusCode
missed out the runtime aspect of the newenum
. (TypeScript enums aren't purely type information, they also include a runtime aspect.) For instance, forHttpStatusCode
it would look like (depending on TypeScript settings):But
HttpStatusCode
doesn't appear anywhere in the current axios other thanindex.d.ts
.Without the runtime part, you get runtime errors trying to use
HttpStatusCode
, see this Stack Overflow question.To Reproduce
Here's a repo with a minimal project to replicate it: https://github.com/tjcrowder/typescript-axios-issue. If you clone it, then
npm install && npm run build && node test.js
, it'll demonstrate the problem.Alternatively, here are steps for creating it from scratch:
npm install axios
npm install --save-dev typescript
test.ts
:"scripts"
to have"build": "tsc test.ts"
npm run build
node test.js
Result:
Code snippet
No response
Expected behavior
It should show 200 for
HttpStatusCode
.Axios Version
1.1.2
Adapter Version
n/a
Browser
n/a
Browser Version
n/a
Node.js Version
16.13.2
OS
Linux Mint v20
Additional Library Versions
No response
Additional context/Screenshots
(What does "Feel free to these instructions before submitting the issue" in the bug report template mean? :-) )
The text was updated successfully, but these errors were encountered: