3π
app
here would be an application instance, which the vue
package exports as App
. And if you want to attach axios
and $http
to the application instance, youβd have to use an any
-type assertion.
π
import type { App } from 'vue';
import axios from 'axios';
axios.defaults.baseURL = process.env.VUE_APP_API_URL;
π
export default (app: App) => {
(app as any).axios = axios;
(app as any).$http = axios;
app.config.globalProperties.axios = axios;
app.config.globalProperties.$http = axios;
}
π€tony19
0π
This is not exactly an error, but rather a warning that if you donβt define a type, the parameter will have the type: any
. In that case, the IDE just advises you to use any
, or whatever type you want
export default (app: any) => {
app.axios = axios;
app.$http = axios;
app.config.globalProperties.axios = axios;
app.config.globalProperties.$http = axios;
}
Is possible to disable this warning adding "noImplicitAny": false
at your tsconfig.json
if you want (:
π€Antony dos Reis
Source:stackexchange.com