language-tools: BUG: JSDocs in wrong place with `vue-tsc --declaration --emitDeclarationOnly`

If I execute:

  • vue-tsc --declaration --emitDeclarationOnly

The JSDocs from my props don’t show up based on the generated MyComponent.d.ts file.

I figured out the correct place for the JSDocs to work properly, so my request is that you duplicate them twice and add them to the correct place as well in the .d.ts file.

input Vue file

<template>
  <div class="pepicon" />
</template>

<script setup lang="ts">
import { defineProps, PropType } from 'vue'
import { Pepicon } from 'pepicons'

defineProps({
  /**
   * The icon name as per the reference at https://pepicons.com
   * @type {'airplane' | 'angle-down'}
   * @example 'airplane'
   */
  name: {
    type: String as PropType<Pepicon>,
    required: true,
  },
})
</script>

current output .d.ts file

With this output the JSDocs don’t show up in Vite Vue 3 project

import { PropType } from 'vue';
import { Pepicon } from 'pepicons';
declare const _default: import("vue").DefineComponent<{
    /**
     * The icon name as per the reference at https://pepicons.com
     * @type {'airplane' | 'angle-down'}
     * @example 'airplane'
     */
    name: {
        type: PropType<Pepicon>;
        required: true;
    };
}, () => void, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
    name?: unknown;
} & {
    name: Pepicon;
} & {}>, {}>;
export default _default;

desired output .d.ts file

With this output the JSDocs show up correctly in Vite Vue 3 project

import { PropType } from 'vue';
import { Pepicon } from 'pepicons';
declare const _default: import("vue").DefineComponent<{
    /**
     * The icon name as per the reference at https://pepicons.com
     * @type {'airplane' | 'angle-down'}
     * @example 'airplane'
     */
    name: {
        type: PropType<Pepicon>;
        required: true;
    };
}, () => void, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
    /**
     * The icon name as per the reference at https://pepicons.com
     * @type {'airplane' | 'angle-down'}
     * @example 'airplane'
     */
    name?: unknown;
} & {
    /**
     * The icon name as per the reference at https://pepicons.com
     * @type {'airplane' | 'angle-down'}
     * @example 'airplane'
     */
    name: Pepicon;
} & {}>, {}>;
export default _default;

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

@mesqueeb It should be a DefineComponent type issue, so I will just send a PR if I can resolve.

@mesqueeb vue-tsc is not relevant to this, you just need to update vue.