Skip to content

'AxiosInstance' is not assignable to parameter of type 'AxiosStatic' #173

Open
@1e4

Description

@1e4

I have http.js configuring axios however when importing it it fails with

src/main.ts(16,19): error TS2769: No overload matches this call.
-- | --
Overload 1 of 2, '(plugin: Plugin<[axios: AxiosStatic]>, axios: AxiosStatic): App<Element>', gave the following error.
Argument of type 'AxiosInstance' is not assignable to parameter of type 'AxiosStatic'.
Type 'AxiosInstance' is missing the following properties from type 'AxiosStatic': create, Cancel, CancelToken, Axios, and 12 more.
Overload 2 of 2, '(plugin: Plugin<[axios: AxiosStatic]>, options: [axios: AxiosStatic]): App<Element>', gave the following error.
Argument of type 'AxiosInstance' is not assignable to parameter of type '[axios: AxiosStatic]'.
src/main.ts(16,19): error TS2769: No overload matches this call.
Overload 1 of 2, '(plugin: Plugin<[axios: AxiosStatic]>, axios: AxiosStatic): App<Element>', gave the following error.
Argument of type 'AxiosInstance' is not assignable to parameter of type 'AxiosStatic'.
Type 'AxiosInstance' is missing the following properties from type 'AxiosStatic': create, Cancel, CancelToken, Axios, and 12 more.
Overload 2 of 2, '(plugin: Plugin<[axios: AxiosStatic]>, options: [axios: AxiosStatic]): App<Element>', gave the following error.
Argument of type 'AxiosInstance' is not assignable to parameter of type '[axios: AxiosStatic]'.
ERROR: "type-check" exited with 2.

http.js

import axios from 'axios'

const http = axios.create({
  baseURL: import.meta.env.VITE_API_URL
});

export default http;

main.js

import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router from './router'

import http from './http'
import VueAxios from 'vue-axios'

const app = createApp(App)

app.use(createPinia())
app.use(router)
app.use(VueAxios, http)

app.mount('#app')

This works fine with javascript and only fails with TypeScript. I'm sure it's something simple to fix. I checked the tickets and saw there may be issues with types and such as there doesn't seem to be full TS support.

Does anyone have a solution for this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions