File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 11import  {  IAsyncComputedValue ,  IAsyncComputedValueBase  }  from  "vue-async-computed" ; 
22import  {  createDecorator ,  VueDecorator  }  from  "vue-class-component" ; 
3+ import  {  DefaultComputed  }  from  "vue/types/options" ; 
34
45export  type  IAsyncComputedOptions < T >  =  IAsyncComputedValueBase < T > ; 
56
67export  default  function  AsyncComputed < TResult > ( 
7-      computedOptions ?: IAsyncComputedOptions < TResult > ) : VueDecorator  { 
8+   computedOptions ?: IAsyncComputedOptions < TResult > ) : VueDecorator  { 
89    return  createDecorator ( ( options ,  key )  =>  { 
910        options . asyncComputed  =  options . asyncComputed  ||  { } ; 
1011
11-         if  ( options . methods  ===  undefined )  { 
12-             throw  new  Error ( "methods is undefined" ) ; 
12+         let  method : DefaultComputed  |  null  =  null 
13+         if  ( options . methods ?. [ key ] )  { 
14+             method  =  options . methods [ key ] 
15+             delete  options . methods [ key ] ; 
16+         }  else  if  ( options . computed ?. [ key ] )  { 
17+             method  =  options . computed [ key ] 
18+             delete  options . computed [ key ] ; 
19+         }  else  { 
20+             throw  new  Error ( `AsyncComputed ${ key }  ) ; 
1321        } 
1422
15-         const  method  =  options . methods [ key ] ; 
16- 
1723        options . asyncComputed [ key ]  =  { 
1824            get : method , 
1925            ...computedOptions , 
2026        }  as  IAsyncComputedValue < TResult > ; 
21- 
22-         delete  options . methods [ key ] ; 
2327    } ) ; 
2428} 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments