diff --git a/types/index.d.ts b/types/index.d.ts index 2adcc41..b2c92dc 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,4 +1,5 @@ -import Vue, { PluginFunction } from 'vue'; +import { PluginFunction } from 'vue'; +import { ComponentOptions, DataDef, RecordPropsDefinition } from 'vue/types/options'; export interface IAsyncComputedOptions { errorHandler?: (error: string | Error) => void; @@ -25,10 +26,6 @@ export interface IAsyncComputedValue extends IAsyncComputedValueBase { get: AsyncComputedGetter; } -export interface AsyncComputedObject { - [K: string]: AsyncComputedGetter | IAsyncComputedValue; -} - export interface IASyncComputedState { state: 'updating' | 'success' | 'error'; updating: boolean; @@ -38,14 +35,33 @@ export interface IASyncComputedState { update: () => void; } -declare module 'vue/types/options' { - interface ComponentOptions { - asyncComputed?: AsyncComputedObject; - } + +export type AsyncComputedObject = { + [K in keyof T] : AsyncComputedGetter | IAsyncComputedValue; +} + +export type AsyncComputedStates = { + $asyncComputed: {[K in keyof T]: IASyncComputedState}; +} + +export interface AsyncComputedOption { + asyncComputed?: AsyncComputedObject; } declare module 'vue/types/vue' { - interface Vue { - $asyncComputed: {[K: string]: IASyncComputedState}; + interface VueConstructor { + extend(options?: + object & + ComponentOptions, V>, Methods, Computed, PropNames[], Record> & + AsyncComputedOption & + ThisType, Readonly>>> + ): ExtendedVue, Record>; + + extend(options?: + object & + ComponentOptions, Methods, Computed, RecordPropsDefinition, Props> & + AsyncComputedOption & + ThisType, Readonly>> + ): ExtendedVue, Props>; } }