3
ComponentPublicInstance,
11
export type StringDictionary<T extends string> = Required<{
15
// Needed to prevent TS to collapse `'value1' | 'value2' | string` to `string`, which breaks first parameter autocomplete
16
// See: https://github.com/microsoft/TypeScript/issues/29729#issuecomment-832522611
17
export type LiteralUnion<T extends U, U = string> =
19
| (U & Record<never, never>);
21
// See: https://stackoverflow.com/a/49936686/7931540
22
export type DeepPartial<T> = {
23
[P in keyof T]?: T[P] extends Array<infer U>
24
? Array<DeepPartial<U>>
25
: T[P] extends ReadonlyArray<infer U>
26
? ReadonlyArray<DeepPartial<U>>
30
// Create a fake constructor signature for a Vue component, needed to correctly extract/infer Component type in many situation,
31
// especially into VTU to automatically infer Quasar components type when using `findComponent`
32
// This type is compatible with the Vue private `ComponentPublicInstanceConstructor` type
33
// https://github.com/vuejs/vue-next/blob/011dee8644bb52f5bdc6365c6e8404936d57e2cd/packages/runtime-core/src/componentPublicInstance.ts#L111
34
export type ComponentConstructor<
35
Component extends ComponentPublicInstance<
41
> = ComponentPublicInstance<any>,
45
C extends ComputedOptions = ComputedOptions,
46
M extends MethodOptions = MethodOptions,
47
> = { new (): Component } & ComponentOptions<Props, RawBindings, D, C, M>;
49
// https://github.com/vuejs/vue-next/blob/d84d5ecdbdf709570122175d6565bb61fae877f2/packages/runtime-core/src/apiDefineComponent.ts#L29-L31
50
// TODO: This can be imported from vue directly once this PR gets merged: https://github.com/vuejs/vue-next/pull/2403
51
export type PublicProps = VNodeProps &
52
AllowedComponentProps &
55
// Can't use `DefineComponent` because of the false prop inferring behavior, it doesn't pick up the required types when an interface is passed
56
// This PR will probably solve the problem as it moves the prop inferring behavior to `defineComponent` function: https://github.com/vuejs/vue-next/pull/4465
57
// GlobalComponentConstructor helper is kind of like the ComponentConstructor type helper, but simpler and keeps the Volar errors simpler,
58
// and also similar to the usage in official Vue packages: https://github.com/vuejs/vue-next/blob/d84d5ecdbdf709570122175d6565bb61fae877f2/packages/runtime-core/src/components/BaseTransition.ts#L258-L264 or https://github.com/vuejs/vue-router-next/blob/5dd5f47515186ce34efb9118dda5aad0bb773439/src/RouterView.ts#L160-L172 etc.
59
// TODO: This can be replaced with `DefineComponent` once this PR gets merged: https://github.com/vuejs/vue-next/pull/4465
60
export type GlobalComponentConstructor<Props = {}, Slots = {}> = {
62
$props: PublicProps & Props;