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

vue/macros breaks auto-imports.d.ts #378

Closed
5 tasks done
DoubleJ-G opened this issue May 22, 2023 · 3 comments
Closed
5 tasks done

vue/macros breaks auto-imports.d.ts #378

DoubleJ-G opened this issue May 22, 2023 · 3 comments

Comments

@DoubleJ-G
Copy link

Describe the bug

Including vue/macros in the imports config for unplugin-auto-import/vite causes the auto-imports.d.ts to incorrectly generate.

In vite.config.ts

import AutoImport from 'unplugin-auto-import/vite'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(),
  AutoImport({
    imports: [
      'vue/macros'
    ],
  })],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})

Broken auto-imports.d.ts:

export {}
declare global {
  const $: typeof import('vue/macros')['
]
  const $: typeof import('vue/macros')['$']
  const $computed: typeof import('vue/macros')['$computed']
  const $customRef: typeof import('vue/macros')['$customRef']
  const $ref: typeof import('vue/macros')['$ref']
  const $shallowRef: typeof import('vue/macros')['$shallowRef']
  const $toRef: typeof import('vue/macros')['$toRef']
}

This seems to be a breaking change from 0.15.3, the latest version it generates correctly to 0.16.0 as this is the earliest version I can find it breaking.

The reproduction provided was created using pnpm create vue with the minimal amount of options selected and for sake of reproduction on vue/macros was included in the AutoImport config but it will also still occur with more selected.

Reproduction

https://github.com/DoubleJ-G/vue-auto-import-macros

System Info

System:
    OS: macOS 12.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 103.63 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.15.0/bin/yarn
    npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm
  Browsers:
    Chrome: 113.0.5672.126
    Safari: 15.3

Used Package Manager

pnpm

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.
@joker77877
Copy link

image
auto-import.d.ts still reports an error.

@antfu
Copy link
Member

antfu commented May 22, 2023

It seems to be a regression of #367, cc @lishaobos

@lishaobos
Copy link
Collaborator

It seems to be a regression of #367, cc @lishaobos它似乎是 #367 的回归,cc @lishaobos

ok, let me check

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

4 participants