unplugin / unplugin-auto-import

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

Using global type in module file #540

Open Ericlm opened 1 week ago

Ericlm commented 1 week ago

Describe the bug

I'm using auto-imports in a Vue project, and while it works perfectly in vue components, I'm having issues with types in .ts files (like composables or stores).

Reproduction

https://github.com/Ericlm/vue-unplugin-auto-import

System Info

System:
    OS: macOS 15.0.1
    CPU: (8) arm64 Apple M1
    Memory: 121.91 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.6.0 - ~/.asdf/installs/nodejs/22.6.0/bin/node
    npm: 10.8.3 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: 9.9.0 - ~/.asdf/installs/nodejs/22.6.0/bin/pnpm
  Browsers:
    Chrome: 129.0.6668.103
    Safari: 18.0.1

Used Package Manager

npm

Validations

Ericlm commented 2 days ago

It works when using a syntax like:

declare global {
  type Ref<T> = import('vue').Ref<T>
}

instead of export type {} inside of declare global {}.

Maybe this syntax should be used instead of export type {}. ?