8 Commits

Author SHA1 Message Date
Ehsan Samavati
f68f9e392f
Refactor/migrate to typescript only (#1484)
* build: initial TypeScript migration

Add TypeScript as a dev dependency
Configure Babel to handle .ts and .tsx files
Add basic TSConfig for starting type checking
Convert src index file to .ts

* chore: make __ssrPromises mutable in index.d.ts

Change __ssrPromises from const to let in index.d.ts to fix the build error:

SyntaxError: Missing initializer in const declaration

This allows __ssrPromises to be initialized later instead of requiring an initializer when declared.

* feat: add typescript types and interfaces

Add typescript type definitions:

AxiosHooksConfig - configuration options
UseAxiosCache - cache object type
UseAxiosOptions - hook options interface
UseAxiosResponse - custom response type
UseAxiosResult - hook return type
This provides typed interfaces for the different configurations, options, and results when using the hooks. Ensures correct TS usage and enables editor auto-complete.

* test: migrate tests to typescript

Remove JavaScript test files
Convert remaining tests to TypeScript
Update Jest config to only run TS tests
Remove no longer needed type declaration files
Update tests to properly mock axios as a typed mock
Fix minor type errors in tests
Add types to test utilities
This finishes migration of the tests to TypeScript for improved compile time checking and takes full advantage of TypeScript in the tests.
2023-11-02 14:08:36 +00:00
Mark Hebden
b222e633f5
feat: update to support axios 1.x (#1418)
* feat: update to support axios 1.x

Updated the following packages too:
 - LRUCache
 - jest
 - ts-jest
 - prettier
 - typescript

* feat: migrate from legacy cancel token to abort controller

* chore: update axios peer dependency

---------

Co-authored-by: Mark Hebden <mark.hebden@airelogic.com>
2023-09-13 21:47:50 +02:00
Simone Busoli
2b0e9a58ed feat: support multiple instances of useAxios configured independently
See README for details about how to use the feature: https://github.com/simoneb/axios-hooks/#multiple-hook-instances

fix #98
2019-11-30 22:48:26 +01:00
Simone Busoli
307c7c1565 fix: do not dispatch state updates when requests are cancelled
fix #74
2019-11-10 18:01:00 +01:00
Simone Busoli
459c1e2d09 test: add names to jest projects for better output and add commit script 2019-11-10 15:48:09 +01:00
Simone Busoli
88829b0206 fix: do not execute manual requests on server 2019-10-19 17:24:01 +02:00
Simone Busoli
076f89a267 refactor: Add tests to check that typescript definitions are correct
Fixes #23
2019-08-05 19:48:20 +02:00
Simone Busoli
a1412a584f test: Add tests 2019-05-26 20:57:42 +02:00