]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(types): fix app.component() typing with inline defineComponent
authorEvan You <yyx990803@gmail.com>
Fri, 3 May 2024 23:29:23 +0000 (16:29 -0700)
committerEvan You <yyx990803@gmail.com>
Fri, 3 May 2024 23:29:23 +0000 (16:29 -0700)
close #10843

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

index aa0cfb0ebab3e3d8afc5ff7fb8678bb4a02cf3e3..4af81be1dec62693dd5b7467e35ded7200947ccc 100644 (file)
@@ -1959,3 +1959,17 @@ declare const ErrorMessage: {
     }
   })
 ;<ErrorMessage name="password" class="error" />
+
+// #10843
+createApp({}).component(
+  'SomeComponent',
+  defineComponent({
+    props: {
+      title: String,
+    },
+    setup(props) {
+      expectType<string | undefined>(props.title)
+      return {}
+    },
+  }),
+)
index 286eb2bcc8e801b96e4b37db0490478c1ed8bdc7..12e63211a49863542bd7a51225e83810b841c806 100644 (file)
@@ -42,7 +42,10 @@ export interface App<HostElement = any> {
 
   mixin(mixin: ComponentOptions): this
   component(name: string): Component | undefined
-  component(name: string, component: Component | DefineComponent): this
+  component<T extends Component | DefineComponent>(
+    name: string,
+    component: T,
+  ): this
   directive<T = any, V = any>(name: string): Directive<T, V> | undefined
   directive<T = any, V = any>(name: string, directive: Directive<T, V>): this
   mount(