From eef948d454f69f93a8e8211bf287bc9dcca2eaba Mon Sep 17 00:00:00 2001 From: David Matter Date: Fri, 9 Aug 2024 07:57:58 +0200 Subject: [PATCH] fix(language-core): nullable modelvalues (#4648) --- .../lib/codegen/script/scriptSetup.ts | 2 +- test-workspace/tsc/vue2/tsconfig.json | 1 + test-workspace/tsc/vue3/#4646/child.vue | 13 +++++++++++++ test-workspace/tsc/vue3/#4646/child2.vue | 5 +++++ test-workspace/tsc/vue3/#4646/parent.vue | 15 +++++++++++++++ 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 test-workspace/tsc/vue3/#4646/child.vue create mode 100644 test-workspace/tsc/vue3/#4646/child2.vue create mode 100644 test-workspace/tsc/vue3/#4646/parent.vue 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 @@ + +