Skip to content

Official way to generate Vue components .d.ts as a Vite plugin #3306

Description

@segevfiner

You can currently get .d.ts files by either:

  1. Manually invoking vue-tsc
  2. Using vite-plugin-dts, which unfortunately doesn't use the same transformation/way to extract types the Vue language services does, and as such has compatibility issues (Many remain unresolved ATM as the other is unresponsive).
  3. Using vite-dts which requires shipping sources and is also unmaintained and doesn't work with newer Vite versions.

This is not ideal, it would be nice to have an official way to generate .d.ts files for Vite built libraries. It's kind of an essential part for any TypeScript built component library.

It would be cool to have an official plugin to generate types during build time based on the Vue language tools. The standard way in Rollup is using rollup-plugin-typescript2 but that doesn't know about Vue. So one way would be to extend it to support Vue. Otherwise any approach which works as a plugin to Vite and works well in build --watch mode will be very very helpful.

Due to not having a proper solution for this we are currently stuck on Vue 3.2 and cannot upgrade to Vue 3.3. qmhc/unplugin-dts#220

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