Closed TristanMNorton closed 1 month ago
Same problem here. I have component who works fine and I move all models usage using defineModel
and now I have this TS Error when I made a globalComponent with app.component
:
L'argument de type '<T extends ({ id: string | number; } | Model)>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<...>) =>...' n'est pas attribuable au paramètre de type 'Component<any, any, any, ComputedOptions, MethodOptions, {}, any> | DefineComponent<{}, {}, {}, ComputedOptions, MethodOptions, ... 14 more ..., any>'.
Impossible d'assigner le type '<T extends ({ id: string | number; } | Model)>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<...>) =>...' au type 'FunctionalComponent<any, {}, any, {}>'.
Les types des paramètres '__VLS_ctx' et 'ctx' sont incompatibles.
Impossible d'assigner le type 'Omit<{ attrs: Data; slots: Readonly<InternalSlots>; emit: (event: string, ...args: any[]) => void; expose: <Exposed extends Record<string, any> = Record<string, any>>(exposed?: Exposed | undefined) => void; }, "expose">' au type '{ slots: {}; attrs: any; emit: ((evt: "fire:event", event: string, item: any) => void) & __VLS_ModelEmitsType; }'.
Les types de la propriété 'emit' sont incompatibles.
Impossible d'assigner le type '(event: string, ...args: any[]) => void' au type '((evt: "fire:event", event: string, item: any) => void) & __VLS_ModelEmitsType'.
Impossible d'assigner le type '(event: string, ...args: any[]) => void' au type '__VLS_ModelEmitsType'.ts(2345)
The problem seems to come from the emit
part, which doesn't seem to want the __VLS_ModelEmitsType
type introduced by defineModel
.
Vue - Official extension or vue-tsc version
2.1.6
VSCode version
1.93.0
Vue version
3.5.3
TypeScript version
5.5.3
System Info
package.json dependencies
Steps to reproduce
Main.ts
HelloWorld.vue
What is expected?
The SFC internally is type safe and should allow for usage of generics when using defineModel.
What is actually happening?
Link to minimal reproduction
No response
Any additional comments?
I at least suspect this is an issue with vue-tsc. I can't reproduce with Vue SFC Playground as I don't have access to the main typescript file.