From ce1df2f9ae3ff832f509520de33f51d9e64a781d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ch=C5=82odnicki?= Date: Thu, 16 Mar 2023 08:26:32 -0700 Subject: [PATCH] fix(types): sync vue type augmentations with Vue 2.7 (#19526) Co-authored-by: Daniel Roe --- packages/types/app/vue.d.ts | 102 +++++++++++++++++++++++++++++++----- 1 file changed, 88 insertions(+), 14 deletions(-) diff --git a/packages/types/app/vue.d.ts b/packages/types/app/vue.d.ts index 655a7bf7f4..596909d05c 100644 --- a/packages/types/app/vue.d.ts +++ b/packages/types/app/vue.d.ts @@ -5,8 +5,9 @@ import type Vue from 'vue' import type { MetaInfo } from 'vue-meta' import type { Route } from 'vue-router' -import type { RecordPropsDefinition, PropsDefinition, ComponentOptions } from 'vue/types/options' -import type { CombinedVueInstance, ExtendedVue } from 'vue/types/vue' +import type { RecordPropsDefinition, ComponentOptions } from 'vue/types/options' +import type { ComponentOptionsMixin } from 'vue/types/v3-component-options' +import type { CombinedVueInstance } from 'vue/types/vue' import type { NuxtRuntimeConfig } from '../config/runtime' import type { Context, Middleware, Transition, NuxtApp } from './index' @@ -26,6 +27,9 @@ declare module 'vue/types/options' { Computed = DefaultComputed, PropsDef = PropsDefinition, Props = DefaultProps, + RawBindings = {}, + Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, + Extends extends ComponentOptionsMixin = ComponentOptionsMixin, /* eslint-enable no-unused-vars,@typescript-eslint/no-unused-vars */ AsyncData = DefaultAsyncData > { @@ -60,7 +64,10 @@ type ThisTypedComponentOptionsWithArrayPropsAndAsyncData< Methods, Computed, PropNames extends string, - AsyncData + SetupBindings, + Mixin extends ComponentOptionsMixin, + Extends extends ComponentOptionsMixin, + AsyncData extends DefaultAsyncData = DefaultAsyncData > = object & ComponentOptions< V, @@ -69,15 +76,21 @@ type ThisTypedComponentOptionsWithArrayPropsAndAsyncData< Computed, PropNames[], Record, - DataDef + Merged>>, + Mixin, + Extends, + AsyncData > & ThisType< CombinedVueInstance< V, - Merged>, + Merged>>, Methods, Computed, - Readonly> + Readonly>, + SetupBindings, + Mixin, + Extends > > export type ThisTypedComponentOptionsWithRecordPropsAndAsyncData< @@ -86,7 +99,10 @@ export type ThisTypedComponentOptionsWithRecordPropsAndAsyncData< Methods, Computed, Props, - AsyncData + SetupBindings, + Mixin extends ComponentOptionsMixin, + Extends extends ComponentOptionsMixin, + AsyncData extends DefaultAsyncData > = object & ComponentOptions< V, @@ -95,12 +111,25 @@ export type ThisTypedComponentOptionsWithRecordPropsAndAsyncData< Computed, RecordPropsDefinition, Props, - DataDef -> & + Merged>>, + Mixin, + Extends, + AsyncData + > & ThisType< - CombinedVueInstance>, Methods, Computed, Readonly> + CombinedVueInstance< + V, + Merged>>, + Methods, + Computed, + Readonly, + SetupBindings, + Mixin, + Extends + > > + declare module 'vue/types/vue' { interface Vue { $config: NuxtRuntimeConfig @@ -113,25 +142,70 @@ declare module 'vue/types/vue' { } } interface VueConstructor { - extend( + /** extend with array props */ + extend< + Data, + Methods, + Computed, + PropNames extends string = never, + SetupBindings = {}, + Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, + Extends extends ComponentOptionsMixin = ComponentOptionsMixin, + AsyncData extends DefaultAsyncData = DefaultAsyncData + >( options?: ThisTypedComponentOptionsWithArrayPropsAndAsyncData< V, Data, Methods, Computed, PropNames, + SetupBindings, + Mixin, + Extends, AsyncData > - ): ExtendedVue> - extend( + ): ExtendedVue< + V, + Data, + Methods, + Computed, + Record, + Merged>>, + Mixin, + Extends + > + + /** extend with object props */ + extend< + Data, + Methods, + Computed, + Props, + SetupBindings = {}, + Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, + Extends extends ComponentOptionsMixin = ComponentOptionsMixin, + AsyncData extends DefaultAsyncData = DefaultAsyncData + >( options?: ThisTypedComponentOptionsWithRecordPropsAndAsyncData< V, Data, Methods, Computed, Props, + SetupBindings, + Mixin, + Extends, AsyncData > - ): ExtendedVue + ): ExtendedVue< + V, + Data, + Methods, + Computed, + Props, + Merged>>, + Mixin, + Extends + > } }