language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

Vue-component-meta | Can't generate defineModel description and tags

Open Fedezable opened this issue 1 year ago • 1 comments

Vue - Official extension or vue-tsc version

2.0.22

VSCode version

1.90.2

Vue version

3.4.30

TypeScript version

5.5.2

System Info

  Binaries:
    Node: 20.14.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (126.0.2592.102)
    Internet Explorer: 11.0.22621.3527

Steps to reproduce

Create a basic script setup ts component with defineModel and generate meta.

<script setup lang="ts">
/**
 * Prop description
 *
 * @tag Tag
 */
defineModel<string>('data')
</script>

<template>
  <div>
    {{ data }}
  </div>
</template>

What is expected?

I'd expect the JSdoc comment associated to defineModel to be assigned to the prop, or alternatively to both the prop and the event.

What is actually happening?

Both prop and event are generated, but still the metadata from JSdoc can't be processed. Description and tags are both empty.

The prop generated:

{
    name: 'data',
    global: false,
    description: '',
    tags: [],
    required: false,
    type: 'string | undefined',
    rawType: undefined,
    declarations: [Getter],
    schema: [Getter]
}

The event generated:

{
    name: 'update:data',
    description: '',
    tags: [],
    type: '[data: string]',
    rawType: undefined,
    signature: '(event: "update:data", data: string): void',
    declarations: [Getter],
    schema: [Getter]
}

Link to minimal reproduction

No response

Any additional comments?

No response

Fedezable avatar Jul 17 '24 12:07 Fedezable

What are you using to generate the JSDoc?

davidmatter avatar Aug 08 '24 09:08 davidmatter

I encountered a similar issue:

The JSDoc description for defineProps can be retrieved normally.

However, the JSDoc description for defineEmits cannot be retrieved properly.


My component code:


<script setup lang="ts">
interface Props {
  /**
   * 卡片的 title        <-- JSDoc description info of props...
   */
  title?: string
}
defineProps<Props>()

interface Emits {
  /**
   * 卡片的 showMessage        <-- JSDoc description info of emits...
   */
  showMessage: [msg: string]
}
const emits = defineEmits<Emits>()
</script>

I got:

image


Is this an unknown bug in the vue-component-meta package, or is it designed this way?

liangpengyv avatar Dec 16 '24 09:12 liangpengyv