vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.83k stars 395 forks source link

Dynamic props in custom global components not working #1875

Closed szulcus closed 2 years ago

szulcus commented 2 years ago

In ~/@types/components.d.ts I have a component defined as follows:

declare module '@vue/runtime-core' {
    import Vue from 'vue';
    // @nuxtjs/svg-sprite module
    class SvgIcon extends Vue {
        $props: {
            name: string;
            title?: string;
            desc?: string;
            class?: string;
        };
    }

    export interface GlobalComponents {
        'svg-icon': typeof SvgIcon;
    }
}

When trying to pass the name property as dynamic, I get the following error:

No overload matches this call.
  Overload 1 of 3, '(options?: ThisTypedComponentOptionsWithArrayProps<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, ...>>, ... 6 more ..., ComponentOptionsMixin>): SvgIcon', gave the following error.
  Overload 2 of 3, '(options?: ThisTypedComponentOptionsWithRecordProps<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, ...>>, ... 6 more ..., ComponentOptionsMixin>): SvgIcon', gave the following error.
  Overload 3 of 3, '(options?: ComponentOptions<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, ...>>, ... 7 more ..., ComponentOptionsMixin>): SvgIcon', gave the following error.ts(2769)
components.d.ts(18, 4): 'name' is declared here.
components.d.ts(18, 4): 'name' is declared here.
components.d.ts(18, 4): 'name' is declared here.

image

A temporary solution is to make the name property optional, but I hope you can fix that. Thank you in advance! ❤️

johnsoncodehk commented 2 years ago

I can't reproduce this problem in v0.40.13 and v1.0.8, could you provide repro case?

szulcus commented 1 year ago

Thank you for your reply and sorry for the lack of response on my part. I didn't notice the notification. In the latest version it works. You can remove the label "need more info / repro".