unplugin / unplugin-auto-import

Auto import APIs on-demand for Vite, Webpack and Rollup
MIT License
3.29k stars 198 forks source link

Axios type export? #260

Closed qinfeng0214 closed 2 years ago

qinfeng0214 commented 2 years ago

I want to ask you, when I export types AxiosRequestConfig and AxiosResponse from Axios, an error occurs I used it this way before: import type { AxiosRequestConfig, AxiosResponse } from 'axios' Now use unplugin-auto-import

imports: [
  'vue',
  'vue-router',
  'pinia',
  {
      axios: ['AxiosRequestConfig', 'AxiosResponse', ['default', 'axios']]
  }
],

auto-import.d.ts:

declare global {
    // error: Property 'AxiosRequestConfig' does not exist on type 'typeof import("g:/project/vue3-ts-pinia/node_modules/axios/index")'.ts
    const AxiosRequestConfig: typeof import('axios')['AxiosRequestConfig']  
    // error: Property 'AxiosResponse' does not exist on type 'typeof import("g:/project/vue3-ts-pinia/node_modules/axios/index")'.
    const AxiosResponse: typeof import('axios')['AxiosResponse']
}

What should I do?

Thank you very much.

antfu commented 2 years ago

https://github.com/antfu/unplugin-auto-import/issues/61