Skip to content
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

Bug: error during build phase #778

Open
ilteoood opened this issue Jan 22, 2024 · 4 comments
Open

Bug: error during build phase #778

ilteoood opened this issue Jan 22, 2024 · 4 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ilteoood
Copy link

ilteoood commented Jan 22, 2024

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'.
@ilteoood ilteoood added bug Something isn't working triage Needs triage labels Jan 22, 2024
@arthurfiorette
Copy link
Owner

Hey @ilteoood can you provide a reproducible example?

@arthurfiorette
Copy link
Owner

related: #746 and #759

@ilteoood
Copy link
Author

@arthurfiorette Sorry for making you wait, I had a busy week.
here is the repro: https://github.com/ilteoood/interceptor-repro

@arthurfiorette
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants