Bug: error during build phase
ilteoood opened this issue · comments
What happened?
Upgrading from v1.4.1 to v1.5.1, the following error is thrown during the build phase:
Argument of type 'import("/home/runner/work/node_modules/axios/index").AxiosInstance' is not assignable to parameter of type 'import("/home/runner/work/node_modules/axios/index", { with: { "resolution-mode": "import" } }).AxiosInstance'.
This is my tsconfig
{
"compilerOptions": {
"module": "Node16",
"esModuleInterop": true,
"allowJs": true,
"allowSyntheticDefaultImports": true,
"target": "ESNext",
"noImplicitAny": true,
"moduleResolution": "node16",
"resolveJsonModule": true,
"sourceMap": true,
"outDir": "dist",
"skipLibCheck": true,
},
"include": [
"src/**/*"
]
}
axios-cache-interceptor version
1.5.1
Node / Browser Version
20.10.0
Axios Version
1.6.5
What storage is being used
Memory Storage
Relevant debugging log output
Argument of type 'import("/home/runner/work/node_modules/axios/index").AxiosInstance' is not assignable to parameter of type 'import("/home/runner/work/node_modules/axios/index", { with: { "resolution-mode": "import" } }).AxiosInstance'.
Hey @ilteoood can you provide a reproducible example?
@arthurfiorette Sorry for making you wait, I had a busy week.
here is the repro: https://github.com/ilteoood/interceptor-repro
I'm not sure how I'd be able to resolve this issue. Since axios introduced axios/axios#5196, it now ships two different typings, one for cjs and other for esm. This is breaking any library that uses the opposite typing.
The issue breaks down to when both axios's esm and cjs typings are compared:
Argument of type 'import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index").AxiosInstance' is not assignable to parameter of type 'import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index", { with: { "resolution-mode": "import" } }).AxiosInstance'.
Types of property 'defaults' are incompatible.
Type 'Omit<import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index").AxiosDefaults<any>, "headers"> & { headers: import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index").HeadersDefaults & { ...; }; }' is not assignable to type 'Omit<import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index", { with: { "resolution-mode": "import" } }).AxiosDefaults<any>, "headers"> & { headers: import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index", { with: { "resolution-mode": ...'.
Type 'Omit<AxiosDefaults<any>, "headers"> & { headers: HeadersDefaults & { [key: string]: AxiosHeaderValue; }; }' is not assignable to type 'Omit<AxiosDefaults<any>, "headers">'.
Types of property 'transformRequest' are incompatible.
Type 'import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index").AxiosRequestTransformer | import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index").AxiosRequestTransformer[]' is not assignable to type 'import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index", { with: { "resolution-mode": "import" } }).AxiosRequestTransformer | import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index", { with: { "resolution-mode": "import" } }).AxiosRequ...'.
Type 'AxiosRequestTransformer' is not assignable to type 'AxiosRequestTransformer | AxiosRequestTransformer[]'.
Type 'import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index").AxiosRequestTransformer' is not assignable to type 'import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index", { with: { "resolution-mode": "import" } }).AxiosRequestTransformer'.
The 'this' types of each signature are incompatible.
Type 'import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index", { with: { "resolution-mode": "import" } }).InternalAxiosRequestConfig<any>' is not assignable to type 'import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index").InternalAxiosRequestConfig<any>'.
Types of property 'headers' are incompatible.
Type 'import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index", { with: { "resolution-mode": "import" } }).AxiosRequestHeaders' is not assignable to type 'import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index").AxiosRequestHeaders'.
Type 'AxiosRequestHeaders' is not assignable to type 'Partial<RawAxiosHeaders & { Accept: AxiosHeaderValue; "Content-Length": AxiosHeaderValue; "User-Agent": AxiosHeaderValue; "Content-Encoding": AxiosHeaderValue; Authorization: AxiosHeaderValue; } & { ...; }>'.
Types of property 'Accept' are incompatible.
Type 'import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index", { with: { "resolution-mode": "import" } }).AxiosHeaderValue' is not assignable to type 'import("/home/runner/work/node_modules/.pnpm/axios@1.6.7/node_modules/axios/index").AxiosHeaderValue'.
Type 'AxiosHeaders' is not assignable to type 'AxiosHeaderValue'.
Type 'AxiosHeaders' is missing the following properties from type 'string[]': length, pop, push, join, and 33 more.ts(2345)
Maybe axios.AxiosInstance
(cjs) and AxiosInstance
(esm) types aren't compatible with each other??
Any help is appreciated.