Skip to content

After the vue component is assigned to another variable, the original jsDoc annotation in the variable's type declaration is deleted #5335

Open
@shens3

Description

@shens3

Vue - Official extension or vue-tsc version

Vue - Official extension: 2.2.10 ; vue-tsc:2.2.8

VSCode version

1.98.1

Vue version

3.5.13

TypeScript version

5.8.3

System Info

System:
    OS: macOS 13.2.1
    CPU: (6) x64 Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz
    Memory: 200.01 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 22.11.0 - ~/.volta/tools/image/node/22.11.0/bin/node
    Yarn: 1.22.22 - ~/.volta/tools/image/node/22.11.0/bin/yarn
    npm: 10.9.0 - ~/.volta/tools/image/node/22.11.0/bin/npm
  Browsers:
    Chrome: 135.0.7049.96
    Safari: 16.3
    Safari Technology Preview: 14.1

package.json dependencies

{
  "dependencies": {
    "vue": "^3.5.13"
  },
  "devDependencies": {
    "@vitejs/plugin-vue": "^5.2.1",
    "@vue/tsconfig": "^0.7.0",
    "typescript": "~5.8.3",
    "vite": "^6.1.0",
    "vue-tsc": "^2.2.8"
  },
}

Steps to reproduce

Clone the repo, execute the following command

pnpm i 
pnpm build

In the src directory, the main.ts file references Component.vue, assigns it to MyComponent, and exports it as the default.

After executing the command, js and d.ts files corresponding to the src directory were generated in the dist directory. It can be found that in main.d.ts, the comments in the source code were deleted, while the comments were retained in Component.vue.d.ts.

main.d.ts

Image

Component.d.ts

Image

When importing components from main.js, the relevant information in jsdoc cannot be obtained.

The specific phenomenon can be viewed in the Test.vue file.

The difference can be seen <MyComponentFromDistReExport /> and <MyComponentFromDistSrc /> propWithoutDefault.

Image

Image

Also, whether prop has a default value will also affect whether the annotation can be displayed, you can see the <MyComponentFromDistSrc /> difference between propWithoutDefault and propWithDefault.

Image

Image

Miraculously, when using main.ts directly, everything works fine.

Image

Image

What is expected?

Hope all situations can make jsdoc display normally.

What is actually happening?

Jsdoc cannot be displayed normally in some cases.

Link to minimal reproduction

https://github.com/shens3/my-vue-app

Any additional comments?

When the vue component is compiled and published as an npm package for others to use, some parameter information may not be displayed properly to users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good reproduction ✨This issue provides a good reproduction, we will be able to investigate it firstneed info

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions