@@ -3,17 +3,23 @@ import { DecoratedClass } from './declarations'
3
3
4
4
export const noop = ( ) => { }
5
5
6
- export function createDecorator (
7
- factory : ( options : ComponentOptions < Vue > , key : string ) => void
8
- ) : ( target : Vue , key : string ) => void
9
- export function createDecorator (
10
- factory : ( options : ComponentOptions < Vue > , key : string , index : number ) => void
11
- ) : ( target : Vue , key : string , index : number ) => void
12
- export function createDecorator (
13
- factory : ( options : ComponentOptions < Vue > , key : string , index : number ) => void
14
- ) : ( target : Vue , key : string , index : any ) => void {
15
- return ( target , key , index ) => {
16
- const Ctor = target . constructor as DecoratedClass
6
+ export interface VueDecorator {
7
+ // Class decorator
8
+ ( Ctor : typeof Vue ) : void
9
+
10
+ // Property decorator
11
+ ( target : Vue , key : string ) : void
12
+
13
+ // Parameter decorator
14
+ ( target : Vue , key : string , index : number ) : void
15
+ }
16
+
17
+ export function createDecorator ( factory : ( options : ComponentOptions < Vue > , key : string , index : number ) => void ) : VueDecorator {
18
+ return ( target : Vue | typeof Vue , key ?: any , index ?: any ) => {
19
+ const Ctor = typeof target === 'function'
20
+ ? target as DecoratedClass
21
+ : target . constructor as DecoratedClass
22
+
17
23
if ( ! Ctor . __decorators__ ) {
18
24
Ctor . __decorators__ = [ ]
19
25
}
0 commit comments