1
- import Vue , { PluginFunction } from 'vue' ;
1
+ import { PluginFunction } from 'vue' ;
2
+ import { ComponentOptions , DataDef , RecordPropsDefinition } from 'vue/types/options' ;
2
3
3
4
export interface IAsyncComputedOptions {
4
5
errorHandler ?: ( error : string | Error ) => void ;
@@ -25,10 +26,6 @@ export interface IAsyncComputedValue<T> extends IAsyncComputedValueBase<T> {
25
26
get : AsyncComputedGetter < T > ;
26
27
}
27
28
28
- export interface AsyncComputedObject {
29
- [ K : string ] : AsyncComputedGetter < any > | IAsyncComputedValue < any > ;
30
- }
31
-
32
29
export interface IASyncComputedState {
33
30
state : 'updating' | 'success' | 'error' ;
34
31
updating : boolean ;
@@ -38,14 +35,33 @@ export interface IASyncComputedState {
38
35
update : ( ) => void ;
39
36
}
40
37
41
- declare module 'vue/types/options' {
42
- interface ComponentOptions < V extends Vue > {
43
- asyncComputed ?: AsyncComputedObject ;
44
- }
38
+
39
+ export type AsyncComputedObject < T > = {
40
+ [ K in keyof T ] : AsyncComputedGetter < T [ K ] > | IAsyncComputedValue < T [ K ] > ;
41
+ }
42
+
43
+ export type AsyncComputedStates < T > = {
44
+ $asyncComputed : { [ K in keyof T ] : IASyncComputedState } ;
45
+ }
46
+
47
+ export interface AsyncComputedOption < T > {
48
+ asyncComputed ?: AsyncComputedObject < T > ;
45
49
}
46
50
47
51
declare module 'vue/types/vue' {
48
- interface Vue {
49
- $asyncComputed : { [ K : string ] : IASyncComputedState } ;
52
+ interface VueConstructor < V extends Vue = Vue > {
53
+ extend < Data , Methods , Computed , PropNames extends string = never , AsyncComputed = { } > ( options ?:
54
+ object &
55
+ ComponentOptions < V , DataDef < Data , Record < PropNames , any > , V > , Methods , Computed , PropNames [ ] , Record < PropNames , any > > &
56
+ AsyncComputedOption < AsyncComputed > &
57
+ ThisType < CombinedVueInstance < V , Data , Methods , Computed & AsyncComputed & AsyncComputedStates < AsyncComputed > , Readonly < Record < PropNames , any > > > >
58
+ ) : ExtendedVue < V , Data , Methods , Computed & AsyncComputed & AsyncComputedStates < AsyncComputed > , Record < PropNames , any > > ;
59
+
60
+ extend < Data , Methods , Computed , Props , AsyncComputed = { } > ( options ?:
61
+ object &
62
+ ComponentOptions < V , DataDef < Data , Props , V > , Methods , Computed , RecordPropsDefinition < Props > , Props > &
63
+ AsyncComputedOption < AsyncComputed > &
64
+ ThisType < CombinedVueInstance < V , Data , Methods , Computed & AsyncComputed & AsyncComputedStates < AsyncComputed > , Readonly < Props > > >
65
+ ) : ExtendedVue < V , Data , Methods , Computed & AsyncComputed & AsyncComputedStates < AsyncComputed > , Props > ;
50
66
}
51
67
}
0 commit comments