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

Using global type in module file #540

Open
5 tasks done
Ericlm opened this issue Oct 22, 2024 · 2 comments
Open
5 tasks done

Using global type in module file #540

Ericlm opened this issue Oct 22, 2024 · 2 comments

Comments

@Ericlm
Copy link

Ericlm commented Oct 22, 2024

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).

  • In .ts file without import/export, the Ref (or other types) are unknown, but the ref() etc. functions are not reported.
  • It works only when using globalThis (globalThis.Ref)

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

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@Ericlm
Copy link
Author

Ericlm commented Oct 30, 2024

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 {}. ?

@Beeee0927
Copy link

same

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

2 participants