Skip to content

[Docs] auto-import type declarations might not generated in the integration with vue projecrs #6769

Description

@ParsaJR

Package

v4.x

Description

We know that Nuxt UI uses unplugin-auto-import and unplugin-vue-components vite plugins, which should generate the files:

  • auto-imports.d.ts
  • components.d.ts

on development/production environments.

The problem is that these declaration files are generated by Vite plugins, while the default Vue project boilerplate currently uses the following build setup:

{
  "name": "vue-project",
  "version": "0.0.0",
  "private": true,
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "run-p type-check \"build-only {@}\" --",
    "preview": "vite preview",
    "build-only": "vite build",
    "type-check": "vue-tsc --build"
  },
  "dependencies": {
    "vue": "^3.5.40"
  }
}

The build script above runs two processes in parallel : type-checking, vite build process.

This can create a race condition, because vue-tsc can possibly start before the Vite plugins, that have generated the required declaration files.

For example, a clean build may fail with a message like this:

error TS2304: Cannot find name 'useToast'.

This is expected because vue-tsc has no knowledge of the Nuxt UI auto-imports until auto-imports.d.ts has been generated.

I think it worth mentioning in Vue specific docs, as this is the default boilerplate of package.json that many people use.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageAwaiting initial review and prioritization

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions