diff --git a/packages/language-core/lib/codegen/script/scriptSetup.ts b/packages/language-core/lib/codegen/script/scriptSetup.ts index 07024b5757..36cdb4aa15 100644 --- a/packages/language-core/lib/codegen/script/scriptSetup.ts +++ b/packages/language-core/lib/codegen/script/scriptSetup.ts @@ -413,7 +413,7 @@ function* generateDefinePropType(scriptSetup: NonNullable, p } else if ((defineProp.name && defineProp.nameIsString) || !defineProp.nameIsString) { // Infer from actual prop declaration code - yield `NonNullable`; + yield `typeof ${propName}['value']`; } else if (defineProp.defaultValue) { // Infer from defineProp({default: T}) diff --git a/test-workspace/tsc/vue2/tsconfig.json b/test-workspace/tsc/vue2/tsconfig.json index 9aaa7ba292..a425bb6dd7 100644 --- a/test-workspace/tsc/vue2/tsconfig.json +++ b/test-workspace/tsc/vue2/tsconfig.json @@ -21,6 +21,7 @@ "../vue3/#4327", "../vue3/#4512", "../vue3/#4540", + "../vue3/#4646", "../vue3/components", "../vue3/defineEmits", "../vue3/defineModel", diff --git a/test-workspace/tsc/vue3/#4646/child.vue b/test-workspace/tsc/vue3/#4646/child.vue new file mode 100644 index 0000000000..89d4a68525 --- /dev/null +++ b/test-workspace/tsc/vue3/#4646/child.vue @@ -0,0 +1,13 @@ + + + diff --git a/test-workspace/tsc/vue3/#4646/child2.vue b/test-workspace/tsc/vue3/#4646/child2.vue new file mode 100644 index 0000000000..3c9de244f0 --- /dev/null +++ b/test-workspace/tsc/vue3/#4646/child2.vue @@ -0,0 +1,5 @@ + + + diff --git a/test-workspace/tsc/vue3/#4646/parent.vue b/test-workspace/tsc/vue3/#4646/parent.vue new file mode 100644 index 0000000000..136a744672 --- /dev/null +++ b/test-workspace/tsc/vue3/#4646/parent.vue @@ -0,0 +1,15 @@ + +