Explorar o código

fix(types): ensure `this.$props` type does not include `string` (#12123)

close #12122
Tycho hai 1 ano
pai
achega
704173e242

+ 10 - 0
packages-private/dts-test/defineComponent.test-d.tsx

@@ -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)
+  },
+})

+ 1 - 1
packages/runtime-core/src/apiDefineComponent.ts

@@ -265,7 +265,7 @@ export function defineComponent<
         Mixin,
         Extends,
         ResolvedEmits,
-        RuntimeEmitsKeys,
+        {},
         {},
         false,
         InjectOptions,