unplugin / unplugin-vue-components

📲 On-demand components auto importing for Vue
https://www.npmjs.com/package/unplugin-vue-components
MIT License
3.66k stars 341 forks source link

vite.d.ts ts(2349): This expression is not callable #699

Closed XBIsland closed 9 months ago

XBIsland commented 9 months ago

Describe the bug

I referenced the unplugin-auto-import/vite plug-in in the new project, but the typescript compilation reported an error, as shown in the figure below. image

this is my vite config:

import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
import { VantResolver } from '@vant/auto-import-resolver'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
    Components({
      resolvers: [VantResolver()],
      dts: 'typings/vue-component.d.ts'
    }),
    AutoImport({
      imports: ['vue', 'vue-router'],
      dts: 'typings/auto-import.d.ts',
      eslintrc: {
        enabled: false // <-- this
      }
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})

Reproduction

https://github.com/XBIsland/issue-vite-demo-1

System Info

System: Windows
Node: 18.17.1
Typescript: 5.2

Used Package Manager

yarn

Validations

XBIsland commented 9 months ago

I downgraded typescript to 5.16 and the issue was resolved, while I'm still not sure if it's because of the typescript version