Skip to content

Commit

Permalink
fix: handle new Vue 2.7 extend generics
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Mar 16, 2023
1 parent f2a2246 commit 0d96953
Showing 1 changed file with 82 additions and 12 deletions.
94 changes: 82 additions & 12 deletions packages/types/app/vue.d.ts
Expand Up @@ -64,7 +64,10 @@ type ThisTypedComponentOptionsWithArrayPropsAndAsyncData<
Methods,
Computed,
PropNames extends string,
AsyncData
SetupBindings,
Mixin extends ComponentOptionsMixin,
Extends extends ComponentOptionsMixin,
AsyncData extends DefaultAsyncData<V> = DefaultAsyncData<V>
> = object &
ComponentOptions<
V,
Expand All @@ -73,15 +76,21 @@ type ThisTypedComponentOptionsWithArrayPropsAndAsyncData<
Computed,
PropNames[],
Record<PropNames, any>,
DataDef<AsyncData, PropNames, V>
SetupBindings,
Mixin,
Extends,
AsyncData
> &
ThisType<
CombinedVueInstance<
V,
Merged<Data, Awaited<AsyncData>>,
Merged<Data, Awaited<ReturnType<AsyncData>>>,
Methods,
Computed,
Readonly<Record<PropNames, any>>
Readonly<Record<PropNames, any>>,
SetupBindings,
Mixin,
Extends
>
>
export type ThisTypedComponentOptionsWithRecordPropsAndAsyncData<
Expand All @@ -90,7 +99,10 @@ export type ThisTypedComponentOptionsWithRecordPropsAndAsyncData<
Methods,
Computed,
Props,
AsyncData
SetupBindings,
Mixin extends ComponentOptionsMixin,
Extends extends ComponentOptionsMixin,
AsyncData extends DefaultAsyncData<V>
> = object &
ComponentOptions<
V,
Expand All @@ -99,12 +111,25 @@ export type ThisTypedComponentOptionsWithRecordPropsAndAsyncData<
Computed,
RecordPropsDefinition<Props>,
Props,
DataDef<AsyncData, Props, V>
> &
SetupBindings,
Mixin,
Extends,
AsyncData
> &
ThisType<
CombinedVueInstance<V, Merged<Data, Awaited<AsyncData>>, Methods, Computed, Readonly<Props>>
CombinedVueInstance<
V,
Merged<Data, Awaited<ReturnType<AsyncData>>>,
Methods,
Computed,
Readonly<Props>,
SetupBindings,
Mixin,
Extends
>
>


declare module 'vue/types/vue' {
interface Vue {
$config: NuxtRuntimeConfig
Expand All @@ -117,25 +142,70 @@ declare module 'vue/types/vue' {
}
}
interface VueConstructor<V extends Vue> {
extend<Data, Methods, Computed, PropNames extends string, AsyncData>(
/** extend with array props */
extend<
Data,
Methods,
Computed,
PropNames extends string = never,
SetupBindings = {},
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
AsyncData extends DefaultAsyncData<V> = DefaultAsyncData<V>
>(
options?: ThisTypedComponentOptionsWithArrayPropsAndAsyncData<
V,
Data,
Methods,
Computed,
PropNames,
SetupBindings,
Mixin,
Extends,
AsyncData
>
): ExtendedVue<V, Data, Methods, Computed, Record<PropNames, any>>
extend<Data, Methods, Computed, Props, AsyncData>(
): ExtendedVue<
V,
Data,
Methods,
Computed,
Record<PropNames, any>,
SetupBindings,
Mixin,
Extends
>

/** extend with object props */
extend<
Data,
Methods,
Computed,
Props,
SetupBindings = {},
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
AsyncData extends DefaultAsyncData<V> = DefaultAsyncData<V>
>(
options?: ThisTypedComponentOptionsWithRecordPropsAndAsyncData<
V,
Data,
Methods,
Computed,
Props,
SetupBindings,
Mixin,
Extends,
AsyncData
>
): ExtendedVue<V, Data, Methods, Computed, Props>
): ExtendedVue<
V,
Data,
Methods,
Computed,
Props,
SetupBindings,
Mixin,
Extends
>
}
}

0 comments on commit 0d96953

Please sign in to comment.