Skip to content

[vue-component-meta] JSDoc tags in defineEmits are not included in generated EventMeta #5341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
oljc opened this issue Apr 27, 2025 · 6 comments

Comments

@oljc
Copy link

oljc commented Apr 27, 2025

Vue version

3.5.13

TypeScript version

5.8.3

Steps to reproduce

Define defineEmits in Vue’s <script setup> syntax as follows:

const emit = defineEmits<{
  /**
   * @zh 点击时触发
   * @en Emitted when the link is clicked
   */
  (e: 'click', ev: MouseEvent): void;
  /**
   * @zh 用户点击链接时触发
   * @en Triggered when the user clicks on the link
   */
  (e: 'select', hash: string | undefined, preHash: string): void;
}>();
Image

Parse the output:

[
  {
    name: 'click',
    description: '',
    tags: [],
    type: '[ev: MouseEvent]',
    rawType: undefined,
    signature: '(event: "click", ev: MouseEvent): void',
    declarations: [Getter],
    schema: [Getter]
  },
  {
    name: 'select',
    description: '',
    tags: [],
    type: '[hash: string, preHash: string]',
    rawType: undefined,
    signature: '(event: "select", hash: string, preHash: string): void',
    declarations: [Getter],
    schema: [Getter]
  }
]

What is expected?

Tags in JSDoc comments for defineEmits should be extracted correctly, just like they are for Props.

What is actually happening?

does not correctly extract tags from JSDoc comments when parsing components.

Link to minimal reproduction

No response

Any additional comments?

No response

@KazariEX
Copy link
Member

Which version of vue-component-meta did you use? I cannot reproduce this.

Image

@oljc
Copy link
Author

oljc commented Apr 27, 2025

@KazariEX I’m using the latest version.
repro: https://stackblitz.com/edit/vitejs-vite-ajyz7qdb?file=scripts%2Fdocgen.ts
You can add Terminal run npm run docgen to see the issue.

@KazariEX
Copy link
Member

Yes I can reproduce it at stackblitz but cannot do it locally. I don't know how to investigate it.

Image

It is worth noting that the types generated on stacklitz do not seem to be correct either.

@oljc
Copy link
Author

oljc commented Apr 27, 2025

I’m seeing the same issue locally — tags from defineEmits aren’t being extracted correctly, just like in the Stackblitz example. Meanwhile, extracting from defineProps works as expected. So I suspect it could be a bug in vue-component-meta, and I’m still investigating on my side as well.

@oljc
Copy link
Author

oljc commented Apr 27, 2025

I cloned the repository and modified the test cases under the component-meta/reference-type-events directory, it extracts correctly there. However, in my own project and the Stackblitz example, the issue still exists. 🤔

@gcaaa31928
Copy link

I feel like this issue probably exists in the v2 branch rather than the master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants