]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(types): ensure `this.$props` type does not include `string` (#12123)
authorTycho <jh.leong@outlook.com>
Fri, 11 Oct 2024 02:30:09 +0000 (10:30 +0800)
committerGitHub <noreply@github.com>
Fri, 11 Oct 2024 02:30:09 +0000 (10:30 +0800)
close #12122

packages-private/dts-test/defineComponent.test-d.tsx
packages/runtime-core/src/apiDefineComponent.ts

index 9b4c184719c089c8765167ed3131f47e6b730bd2..fda3ca4856c746fd0829458bdea4b0f0ae1b675d 100644 (file)
@@ -2068,3 +2068,13 @@ expectString(instance.actionText)
 // public prop on $props should be optional
 // @ts-expect-error
 expectString(instance.$props.actionText)
+
+// #12122
+defineComponent({
+  props: { foo: String },
+  render() {
+    expectType<{ readonly foo?: string }>(this.$props)
+    // @ts-expect-error
+    expectType<string>(this.$props)
+  },
+})
index 9ae6b41a4dac79c52dc94a02db4e559ee21c575e..2ce870f0141fae4760f13ed3a47281997826af1d 100644 (file)
@@ -265,7 +265,7 @@ export function defineComponent<
         Mixin,
         Extends,
         ResolvedEmits,
-        RuntimeEmitsKeys,
+        {},
         {},
         false,
         InjectOptions,