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

fix: make emits type correct when user assigns emit function a custom name #3624

Merged
merged 4 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/vue-language-core/src/generators/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ export function generate(
codes.push(`expose(exposed: ${scriptSetupRanges.exposeRuntimeArg ? 'typeof __VLS_exposed' : '{}'}): void,\n`);
codes.push('attrs: any,\n');
codes.push('slots: ReturnType<typeof __VLS_template>,\n');
codes.push('emit: typeof __VLS_emit');
codes.push(`emit: typeof ${scriptSetupRanges.emitsAssignName ?? '__VLS_emit'},\n`);
codes.push('};\n');
codes.push('})(),\n');
codes.push(`) => ({} as import('${vueCompilerOptions.lib}').VNode & { __ctx?: Awaited<typeof __VLS_setup> }))`);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script setup lang="ts" generic="T">
defineProps<{
modelValue: T;
}>()

const emit = defineEmits<{
(e: "update:model-value", value: T): void;
}>();
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup lang="ts">
import { exactType } from 'vue-tsc/shared';
import Comp from './Comp.vue';
</script>

<template>
<Comp
model-value="1"
@update:model-value="(e) => exactType(e, '' as string)"
/>
</template>