Skip to content

Typescript: component types does not function correctly when unplugin-auto-import is present #640

@rafael-lua

Description

@rafael-lua

Describe the bug

I just started a fresh project with npm init vue@latest. I installed the plugin latest version and noticed the components are typed as any:

any

Investigating, I thought it could be the new version type change and downgrading to go back to @vue/runtime-core seemed to work again.

However, I noticed the new unplugin-vue-components release did work properly at some point and then stopped. The only other change I did was to also install unplugin-auto-import. And that is what is causing the problem, removing the plugin and deleting the auto-imports.d.ts types made unplugin-vue-components work properly, and the components be correctly typed:

typed

Reproduction

https://github.com/rafael-lua/bug-unplugin-vue-components

System Info

System:
    OS: Linux 5.10 Ubuntu 20.04.5 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
    Memory: 11.38 GB / 12.45 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.16.0/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions