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

refactor: don't generate duplicate virtual code for defineSlots #3581

Merged
merged 1 commit into from
Sep 21, 2023

Conversation

johnsoncodehk
Copy link
Member

@johnsoncodehk johnsoncodehk commented Sep 21, 2023

For defineSlots, we can reuse its return type instead of generating duplicate virtual code for template.

For the following vue code.

<script setup lang="ts">
defineSlots<{
  activator?(props: { isActive: boolean }): void
}>();
</script>

<template>
	<!-- ... -->
</template>

Old virtual code

/* script setup part */
// ...
defineSlots<{
  activator?(props: { isActive: boolean }): void
}>();
// ...

/* template part */
var __VLS_slots!: {
  activator?(props: { isActive: boolean }): void
};
// some template virtual codes reference __VLS_slots

New virtual code

/* script setup part */
// ...
const __VLS_slots = defineSlots<{
  activator?(props: { isActive: boolean }): void
}>();
// ...

/* template part */
// some template virtual codes reference __VLS_slots

@johnsoncodehk johnsoncodehk merged commit 8006c98 into master Sep 21, 2023
6 checks passed
@johnsoncodehk johnsoncodehk deleted the defineSlots branch September 21, 2023 17:50
@johnsoncodehk johnsoncodehk changed the title refactor: don't generate additional virtual code for defineSlots refactor: don't generate duplicate virtual code for defineSlots Sep 21, 2023
@johnsoncodehk
Copy link
Member Author

Also looking to do that for defineEmit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant