Skip to content

Commit

Permalink
fix(language-core): generate value instead of model name into tuple (
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX authored Oct 26, 2024
1 parent 9738d8a commit 06f6f02
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/language-core/lib/codegen/script/scriptSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ function* generateModelEmit(
yield `type __VLS_ModelEmit = {${newLine}`;
for (const defineModel of defineModels) {
const [propName, localName] = getPropAndLocalName(scriptSetup, defineModel);
yield `'update:${propName}': [${propName}:`;
yield `'update:${propName}': [value:`;
yield* generateDefinePropType(scriptSetup, propName, localName, defineModel);
yield `]${endOfLine}`;
}
Expand Down
20 changes: 10 additions & 10 deletions packages/tsc/tests/__snapshots__/dts.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ type __VLS_PrettifyLocal<T> = {
exports[`vue-tsc-dts > Input: generic/component.vue, Output: generic/component.vue.d.ts 1`] = `
"declare const _default: <T>(__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<{
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
readonly "onUpdate:title"?: (title: string) => any;
readonly "onUpdate:title"?: (value: string) => any;
readonly onBar?: (data: number) => any;
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onUpdate:title" | "onBar"> & Partial<{}> & ({
title?: string;
Expand All @@ -111,7 +111,7 @@ exports[`vue-tsc-dts > Input: generic/component.vue, Output: generic/component.v
foo: number;
}): any;
};
emit: ((e: "bar", data: number) => void) & ((evt: "update:title", title: string) => void);
emit: ((e: "bar", data: number) => void) & ((evt: "update:title", value: string) => void);
}>) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> & {
Expand All @@ -127,7 +127,7 @@ type __VLS_PrettifyLocal<T> = {
exports[`vue-tsc-dts > Input: generic/custom-extension-component.cext, Output: generic/custom-extension-component.cext.d.ts 1`] = `
"declare const _default: <T>(__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<{
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
readonly "onUpdate:title"?: (title: string) => any;
readonly "onUpdate:title"?: (value: string) => any;
readonly onBar?: (data: number) => any;
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onUpdate:title" | "onBar"> & Partial<{}> & ({
title?: string;
Expand All @@ -147,7 +147,7 @@ exports[`vue-tsc-dts > Input: generic/custom-extension-component.cext, Output: g
foo: number;
}): any;
};
emit: ((e: "bar", data: number) => void) & ((evt: "update:title", title: string) => void);
emit: ((e: "bar", data: number) => void) & ((evt: "update:title", value: string) => void);
}>) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> & {
Expand Down Expand Up @@ -321,13 +321,13 @@ exports[`vue-tsc-dts > Input: reference-type-model/component.vue, Output: refere
quxModifiers?: Record<'lazy' | 'trim', true>;
};
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_PublicProps>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
"update:foo": (foo: number) => void;
"update:bar": (bar: string[]) => void;
"update:qux": (qux: string) => void;
"update:foo": (value: number) => void;
"update:bar": (value: string[]) => void;
"update:qux": (value: string) => void;
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_PublicProps>>> & Readonly<{
"onUpdate:foo"?: (foo: number) => any;
"onUpdate:bar"?: (bar: string[]) => any;
"onUpdate:qux"?: (qux: string) => any;
"onUpdate:foo"?: (value: number) => any;
"onUpdate:bar"?: (value: string[]) => any;
"onUpdate:qux"?: (value: string) => any;
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
export default _default;
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
Expand Down
3 changes: 3 additions & 0 deletions test-workspace/tsc/passedFixtures/vue3/#4890/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script setup lang="ts" generic="T">
defineModel('hello-world');
</script>

0 comments on commit 06f6f02

Please sign in to comment.