Skip to content

Use type-only import for axios types #541

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

Merged
merged 3 commits into from
Jul 12, 2023
Merged

Use type-only import for axios types #541

merged 3 commits into from
Jul 12, 2023

Conversation

pataiadam
Copy link
Contributor

@pataiadam pataiadam commented Jun 15, 2023

Refactoring the axios imports

The original code was importing both functions and types together from the axios library.
To make the code more readable and follow best practices, I've separated the import statements into two lines.

The first line now imports only the type definitions, i.e., AxiosInstance, AxiosRequestConfig, HeadersDefaults, and ResponseType from axios.
The second line imports the axios library itself.

Note:

I've observed that in Vue projects built with Vite, the current approach does not only cause issues with the linter but also leads to build failures. The build process does not produce runnable code if type imports are not separated from library imports. Although the root cause of this behavior in Vite is unclear for me, these changes address this problem and ensure successful builds.

@pataiadam pataiadam changed the title fix: Use type-only import for axios types WIP: Use type-only import for axios types Jun 16, 2023
@pataiadam pataiadam changed the title WIP: Use type-only import for axios types Use type-only import for axios types Jun 16, 2023
@js2me js2me merged commit 51b3655 into acacode:next Jul 12, 2023
@js2me
Copy link
Member

js2me commented Jul 12, 2023

Thanks for pull request

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.

2 participants