-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathindex.d.ts
67 lines (55 loc) · 2.32 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { PluginFunction } from 'vue';
import { ComponentOptions, DataDef, RecordPropsDefinition } from 'vue/types/options';
export interface IAsyncComputedOptions {
errorHandler?: (error: string | Error) => void;
useRawError?: boolean;
default?: any;
}
export default class AsyncComputed {
constructor(options?: IAsyncComputedOptions);
static install: PluginFunction<never>;
static version: string;
}
export type AsyncComputedGetter<T> = () => Promise<T>;
export interface IAsyncComputedValueBase<T> {
default?: T | (() => T);
watch?: string[] | (() => void);
shouldUpdate?: () => boolean;
lazy?: boolean;
}
export interface IAsyncComputedValue<T> extends IAsyncComputedValueBase<T> {
get: AsyncComputedGetter<T>;
}
export interface IASyncComputedState {
state: 'updating' | 'success' | 'error';
updating: boolean;
success: boolean;
error: boolean;
exception: Error | null;
update: () => void;
}
export type AsyncComputedObject <T> = {
[K in keyof T] : AsyncComputedGetter<T[K]> | IAsyncComputedValue<T[K]>;
}
export type AsyncComputedStates<T> = {
$asyncComputed: {[K in keyof T]: IASyncComputedState};
}
export interface AsyncComputedOption <T> {
asyncComputed?: AsyncComputedObject<T>;
}
declare module 'vue/types/vue' {
interface VueConstructor<V extends Vue = Vue> {
extend<Data, Methods, Computed, PropNames extends string = never, AsyncComputed = {}>(options?:
object &
ComponentOptions<V, DataDef<Data, Record<PropNames, any>, V>, Methods, Computed, PropNames[], Record<PropNames, any>> &
AsyncComputedOption<AsyncComputed> &
ThisType<CombinedVueInstance<V, Data, Methods, Computed & AsyncComputed & AsyncComputedStates<AsyncComputed>, Readonly<Record<PropNames, any>>>>
): ExtendedVue<V, Data, Methods, Computed & AsyncComputed & AsyncComputedStates<AsyncComputed>, Record<PropNames, any>>;
extend<Data, Methods, Computed, Props, AsyncComputed = {}>(options?:
object &
ComponentOptions<V, DataDef<Data, Props, V>, Methods, Computed, RecordPropsDefinition<Props>, Props> &
AsyncComputedOption<AsyncComputed> &
ThisType<CombinedVueInstance<V, Data, Methods, Computed & AsyncComputed & AsyncComputedStates<AsyncComputed>, Readonly<Props>>>
): ExtendedVue<V, Data, Methods, Computed & AsyncComputed & AsyncComputedStates<AsyncComputed>, Props>;
}
}