Skip to content

Commit

Permalink
Update component.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed May 6, 2022
1 parent 4813c9b commit 05cea29
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/runtime-core/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ import { SchedulerJob } from './scheduler'

export type Data = Record<string, unknown>

/**
* Public utility type for extracting the instance type of a component.
* Works with all valid component definition types. This is intended to replace
* the usage of `InstanceType<typeof Comp>` which only works for
* constructor-based component definition types.
*
* Exmaple:
* ```ts
* const MyComp = { ... }
* declare const instance: ComponentInstance<typeof MyComp>
* ```
*/
export type ComponentInstance<T> = T extends { new (): ComponentPublicInstance }
? InstanceType<T>
: T extends FunctionalComponent<infer Props, infer Emits>
Expand Down

0 comments on commit 05cea29

Please sign in to comment.