AlbinoDrought / cachios

Simple axios cache wrapper using node-cache
MIT License
88 stars 10 forks source link

Cant use custom Axios Instance, due some type conflicts between cachios and axios #75

Closed viniciuscasarin closed 2 years ago

viniciuscasarin commented 2 years ago

I'm currently trying to implement the following code, wich is available in this doc https://github.com/AlbinoDrought/cachios#custom-axios-instance

const axios = require('axios');

const axiosInstance = axios.create({
  baseURL: 'https://jsonplaceholder.typicode.com',
});

// all requests will now use this axios instance
const cachiosInstance = cachios.create(axiosInstance);

But my code is throwing this error: Argument of type 'import("*/node_modules/axios/index").AxiosInstance' is not assignable to parameter of type 'import("*/node_modules/cachios/node_modules/axios/index").AxiosInstance'. The types of 'defaults.headers.common' are incompatible between these types. Type 'import("*/node_modules/axios/index").AxiosRequestHeaders' is not assignable to type 'import("*/node_modules/cachios/node_modules/axios/index").AxiosRequestHeaders'. Index signatures are incompatible. Type 'string | number | boolean' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'.

It seems that is happening a conflict between cachios and axios type.

The version of both libs in my package.json: "axios": "^0.27.2", "cachios": "^3.1.2",

Barros42 commented 2 years ago

Up! Same here! I need a fix

murylomf commented 2 years ago

I had the same problem here!

mairascomparim commented 2 years ago

Same problem here :(

AlbinoDrought commented 2 years ago

Hello, thank you for the reports.

Can you please try with cachios@^3.1.3 to see if the issue is resolved?

npm install --save cachios@^3.1.3

Changes: https://github.com/AlbinoDrought/cachios/compare/v3.1.2...v3.1.3

Thanks!

AlbinoDrought commented 2 years ago

Marking this as closed because I believe it's solved.

I added a sample Typescript project here: https://github.com/AlbinoDrought/cachios/tree/master/tests/integration/cachios-typescript

This project gets built against cachios and the latest version of axios here: https://github.com/AlbinoDrought/cachios/blob/master/.github/workflows/typescript-compat.yml

It currently succeeds: https://github.com/AlbinoDrought/cachios/runs/7644727470

viniciuscasarin commented 2 years ago

@AlbinoDrought It's working just fine, thanks for the good work!