Skip to content

Commit

Permalink
fix: generic component prop with default type incorrect
Browse files Browse the repository at this point in the history
close #2754
  • Loading branch information
johnsoncodehk committed May 1, 2023
1 parent c607626 commit 69e2652
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/vue-language-core/src/generators/script.ts
Expand Up @@ -337,13 +337,11 @@ export function generate(

//#region props
if (
(scriptSetupRanges.propsRuntimeArg && scriptSetupRanges.defineProps)
scriptSetupRanges.propsRuntimeArg
|| scriptSetupRanges.defineProp.length
) {
if (scriptSetupRanges.propsRuntimeArg && scriptSetupRanges.defineProps) {
codes.push(`const __VLS_props = `);
addExtraReferenceVirtualCode('scriptSetup', scriptSetupRanges.defineProps.start, scriptSetupRanges.defineProps.end);
codes.push(`;\n`);
if (scriptSetupRanges.propsRuntimeArg) {
codes.push(`const __VLS_props = (new __VLS_publicComponent()).$props;\n`);
}
else if (scriptSetupRanges.defineProp.length) {
codes.push(`const __VLS_defaults = {\n`);
Expand Down
9 changes: 9 additions & 0 deletions packages/vue-test-workspace/vue-tsc/#2754/comp.vue
@@ -0,0 +1,9 @@
<script lang="ts" setup generic="Row extends unknown">
defineProps({
selectAll: {
type: Boolean,
required: false,
default: false,
},
});
</script>
7 changes: 7 additions & 0 deletions packages/vue-test-workspace/vue-tsc/#2754/main.vue
@@ -0,0 +1,7 @@
<template>
<Comp></Comp>
</template>

<script setup lang="ts">
import Comp from './comp.vue';
</script>

0 comments on commit 69e2652

Please sign in to comment.