A TypeScript library that adds full type safety to Axios instances by applying route definitions (generated from OpenAPI or Nextlove) as generic parameters. Current stable version is 3.3.1, actively maintained. Key differentiators: no need for generated client code; works directly with existing Axios instances; supports HTTP method discrimination for precise autocomplete on request/response shapes. Requires peer dependencies axios >=1.0.0 and type-fest >=3.0.0. Ships TypeScript types.
npm install typed-axios-instanceNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows creating a fully typed Axios instance with typed routes, demonstrating POST and GET methods with response types.
Assign the type to an existing Axios instance via `const api: TypedAxios<Routes> = axios.create(...)`.
Generate route types from OpenAPI or Nextlove to ensure they reflect the real API.
Use array syntax `Routes = RouteDef[]` instead of `{ [route:string]: RouteDef }` for per-method autocomplete.Install type-fest as a devDependency: `npm install --save-dev type-fest`
Use `const api: TypedAxios<Routes> = axios.create(...)` instead of `new TypedAxios()`.
Run `npm install --save-dev type-fest` to install the required type utilities.
Ensure each route object has a 'route' (string) and 'method' (HTTP method) property, and optional jsonBody/jsonResponse.
Verify that the route definition includes a valid `jsonResponse` that matches the actual API response body.