Skip to content

issue in runWhen types #7404

@tangerme-jambit

Description

@tangerme-jambit

We were recently trying to update from using axios 1.13.2 to axios 1.13.5.

after the update out build failed with the following Error:

      TS2719: Type 'import("node_modules/axios/index").AxiosInstance' is not assignable to type 'import("node_modules/axios/index").AxiosInstance'. Two different types with this name exist, but they are unrelated.
  The types of 'interceptors.request.handlers' are incompatible between these types.
    Type 'import("node_modules/axios/index").AxiosInterceptorHandler<import("node_modules/axios/index").InternalAxiosRequestConfig<any>>[] | undefined' is not assignable to type 'AxiosInterceptorHandler<import("node_modules/axios/index").InternalAxiosRequestConfig<any>>[] | undefined'.
      Type 'import("node_modules/axios/index").AxiosInterceptorHandler<import("node_modules/axios/index").InternalAxiosRequestConfig<any>>[]' is not assignable to type 'AxiosInterceptorHandler<import("node_modules/axios/index").InternalAxiosRequestConfig<any>>[]'.
        Type 'import("node_modules/axios/index").AxiosInterceptorHandler<import("node_modules/axios/index").InternalAxiosRequestConfig<any>>' is not assignable to type 'AxiosInterceptorHandler<import("node_modules/axios/index").InternalAxiosRequestConfig<any>>'.
          Types of property 'runWhen' are incompatible.
            Type '((config: AxiosRequestConfig<any>) => boolean) | undefined' is not assignable to type '(config: AxiosRequestConfig<any>) => boolean | null'.
              Type 'undefined' is not assignable to type '(config: AxiosRequestConfig<any>) => boolean | null'.

which lead us to the discovery of the types of runWhen being different:
https://github.com/axios/axios/blob/v1.x/index.d.ts#L641C1
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
vs.
https://github.com/axios/axios/blob/v1.x/index.d.ts#L662C1
runWhen: (config: AxiosRequestConfig) => boolean | null;

fixing that locally resolved our issue (locally)

Edit: just for clarification i'm aware of the relation between those 2 types. The first one is what get's provided when registering an Request AxiosInterceptorHandler and the second one is what's being stored in the InterceptorManager.

So in my opinion the second type should (as of now) be the first type | null

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue::bugThis issue is related to a bug that requires fixing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions