1- import Vue , { PluginFunction } from 'vue' ;
1+ import { PluginFunction } from 'vue' ;
2+ import { ComponentOptions , DataDef , RecordPropsDefinition } from 'vue/types/options' ;
23
34export interface IAsyncComputedOptions {
45 errorHandler ?: ( error : string | Error ) => void ;
@@ -25,10 +26,6 @@ export interface IAsyncComputedValue<T> extends IAsyncComputedValueBase<T> {
2526 get : AsyncComputedGetter < T > ;
2627}
2728
28- export interface AsyncComputedObject {
29- [ K : string ] : AsyncComputedGetter < any > | IAsyncComputedValue < any > ;
30- }
31-
3229export interface IASyncComputedState {
3330 state : 'updating' | 'success' | 'error' ;
3431 updating : boolean ;
@@ -38,14 +35,33 @@ export interface IASyncComputedState {
3835 update : ( ) => void ;
3936}
4037
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 > ;
4549}
4650
4751declare 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 , 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 > ;
5066 }
5167}
0 commit comments