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

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

Open
1e4 opened this issue Jun 25, 2024 · 0 comments
Open

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

1e4 opened this issue Jun 25, 2024 · 0 comments

Comments

@1e4
Copy link

1e4 commented Jun 25, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant