forked from foxbenjaminfox/vue-async-computed
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
49 lines (42 loc) · 1.13 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
import Vue, { PluginFunction } from "vue";
interface IAsyncComputedOptions {
errorHandler?: (error: string[]) => void;
useRawError?: boolean;
default?: any;
}
export default class AsyncComputed {
constructor(options?: IAsyncComputedOptions)
static install: PluginFunction<never>;
static version: string;
}
type AsyncComputedGetter<T> = () => (Promise<T> | T);
interface IAsyncComputedProperty<T> {
default?: T | (() => T);
get: AsyncComputedGetter<T>;
watch?: () => void;
shouldUpdate?: () => boolean;
lazy?: boolean;
}
interface IAsyncComputedProperties {
[K: string]: AsyncComputedGetter<any> | IAsyncComputedProperty<any>;
}
declare module "vue/types/options" {
// tslint:disable-next-line:interface-name
interface ComponentOptions<V extends Vue> {
asyncComputed?: IAsyncComputedProperties;
}
}
interface IASyncComputedState {
state: "updating" | "success" | "error";
updating: boolean;
success: boolean;
error: boolean;
exception: Error | null;
update: () => void;
}
declare module "vue/types/vue" {
// tslint:disable-next-line:interface-name
interface Vue {
$asyncComputed: {[K: string]: IASyncComputedState };
}
}