ComponentInstance<T>: T extends (new () => ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string, {}>, {}, {}>)
    ? InstanceType<T>
    : T extends FunctionalComponent<infer Props, infer Emits>
        ? ComponentPublicInstance<Props, {}, {}, {}, {}, ShortEmitsToObject<Emits>>
        : T extends Component<infer Props, infer RawBindings, infer D, infer C, infer M>
            ? ComponentPublicInstance<unknown extends Props
                ? {}
                : Props, unknown extends RawBindings
                ? {}
                : RawBindings, unknown extends D
                ? {}
                : D, C, M>
            : never

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.

Type Parameters

  • T
const MyComp = { ... }
declare const instance: ComponentInstance<typeof MyComp>