Skip to content

Commit

Permalink
fix(language-core): correct logic for defineSlots destructuring (#4326)
Browse files Browse the repository at this point in the history
Co-authored-by: Johnson Chu <[email protected]>
  • Loading branch information
zhiyuanzmj and johnsoncodehk authored Apr 30, 2024
1 parent fd25386 commit d523035
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/language-core/lib/codegen/script/scriptSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,14 @@ function* generateSetupFunction(
}
}
if (scriptSetupRanges.slots.define) {
if (!scriptSetupRanges.slots.name) {
setupCodeModifies.push([[`const __VLS_slots = `], scriptSetupRanges.slots.define.start, scriptSetupRanges.slots.define.start]);
}
else if (scriptSetupRanges.slots.isObjectBindingPattern) {
if (scriptSetupRanges.slots.isObjectBindingPattern) {
setupCodeModifies.push([
[`__VLS_slots;\nconst __VLS_slots = `],
scriptSetupRanges.slots.define.start,
scriptSetupRanges.slots.define.start,
]);
} else if (!scriptSetupRanges.slots.name) {
setupCodeModifies.push([[`const __VLS_slots = `], scriptSetupRanges.slots.define.start, scriptSetupRanges.slots.define.start]);
}
}
if (scriptSetupRanges.emits.define && !scriptSetupRanges.emits.name) {
Expand Down
11 changes: 11 additions & 0 deletions test-workspace/tsc/vue3/#4326/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup lang="ts">
import { exactType } from 'tsc/shared';
const { bottom } = defineSlots<{
bottom: (props: { num: number; }) => any[],
}>();
exactType(bottom, {} as (props: {
num: number;
}) => any[]);
</script>

0 comments on commit d523035

Please sign in to comment.