Skip to content
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

The EmitsToProps typescript utils does not properly retain the function type declarion for emits option. #11470

Open
shenjunjian opened this issue Aug 1, 2024 · 1 comment

Comments

@shenjunjian
Copy link

shenjunjian commented Aug 1, 2024

Vue version

3.4.30

Link to minimal reproduction

https://play.vuejs.org/#eNp9U8uO2zAM/BVClzwQ2If2lDpB220KtEAf6BY96eLadFYbmRL0SFME+fdScuzNAsWeLHE4wyEpn8U7a4tjRLEWlW+csgE8hmhB17TfSBG8FFtJqrfGBTiDww4u0DnTw4xpswn6gL35FXGApCjKFCgSXRJIqspBnbX4ErC3ug7IN4BqpIa/FjezGcDb5oGrI5eXIt2Ubg75sq2yLCczsypvZMSKrTaGOrUvHr0h7uecxKVoTG+VRvfNBmWI/awhIwmrtTZ/PudYcBFXY7x5wObwn/ijP6WYFN8denRHlGLCQu32GAZ4d/8VT3yewN60UXP2C+AP9EbH5HFIex+pZds3edntpzxuRfuffncKSH5sKhlNmZecLwVv5+6F1p/svipeZ56kC0/xujae37TzFjtFWcwQUhj3n0tI8SZtFE85lzPrqPP3ljHPVbFXwU8OyuUSOuWwBUPQaNUc+LgsBzDf520d6jVQ7H+jWwEe1/DFRI+7I0suRh3gJxmio9w/e0kRbmWcg3XGPi/quS+NGZjqpZfHSdfvfXA836vAQMJUE2r/nGboLj/UJ+rHSE2a9a2F/D/NJ8NXu/PFZktR62w5zX6RTuLyDz2BKoA=

Steps to reproduce

In my vscode, create a vue typescript project , pnpm create vite && pnpm i
then copy the code from above playground , I cannot see type declaration on click when I mouse on it

image

What is expected?

export default defineComponent({
  emits: {
    /** fired on clicked */
    click(data: number, ev: MouseEvent) {
      return true;
    }
  }
...............
}

will generate the demo.d.ts as below

Readonly<import('vue').ExtractPropTypes<{
    /** simple prop */
    type: {
        type: StringConstructor;
    };
    /** event as prop */
    onChange: {
        type: FunctionConstructor;
    };
}>> & {
    onClick?: ((data: number, ev: MouseEvent) => any) | undefined;
},

I expect that before onClick line , it comes with type declaration------/** fired on clicked */

What is actually happening?

As in the screenshot, the is no intellisense on click

I think it's easy to fix. I'm locating the problem below:
(

export type EmitsToProps<T extends EmitsOptions> = T extends string[]
)

image

System Info

No response

Any additional comments?

No response

@shenjunjian shenjunjian changed the title The EmitsToProps typescript utils method does not properly retain the function type declarion by emits. The EmitsToProps typescript utils method does not properly retain the function type declarion for emits option. Aug 1, 2024
@shenjunjian shenjunjian changed the title The EmitsToProps typescript utils method does not properly retain the function type declarion for emits option. The EmitsToProps typescript utils does not properly retain the function type declarion for emits option. Aug 1, 2024
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

2 participants