Skip to content

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

@XBIsland

Description

@XBIsland

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

  • 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