import Vue, { PluginFunction } from 'vue'; export interface IAsyncComputedOptions { errorHandler?: (error: string | Error) => void; useRawError?: boolean; default?: any; } export default class AsyncComputed { constructor(options?: IAsyncComputedOptions); static install: PluginFunction; static version: string; } export type AsyncComputedGetter = () => Promise; export interface IAsyncComputedValueBase { default?: T | (() => T); watch?: string[] | (() => void); shouldUpdate?: () => boolean; lazy?: boolean; } export interface IAsyncComputedValue extends IAsyncComputedValueBase { get: AsyncComputedGetter; } export interface AsyncComputedObject { [K: string]: AsyncComputedGetter | IAsyncComputedValue; } export interface IASyncComputedState { state: 'updating' | 'success' | 'error'; updating: boolean; success: boolean; error: boolean; exception: Error | null; update: () => void; } declare module 'vue/types/options' { interface ComponentOptions { asyncComputed?: AsyncComputedObject; } } declare module 'vue/types/vue' { interface Vue { $asyncComputed: {[K: string]: IASyncComputedState}; } }