@@ -3,17 +3,22 @@ import { DecoratedClass } from './declarations'
33
44export const noop = ( ) => { }
55
6- export function createDecorator (
7- factory : ( options : ComponentOptions < any , any , any , any > , key : string ) => void
8- ) : ( target : Vue , key : string ) => void
9- export function createDecorator (
10- factory : ( options : ComponentOptions < any , any , any , any > , key : string , index : number ) => void
11- ) : ( target : Vue , key : string , index : number ) => void
12- export function createDecorator (
13- factory : ( options : ComponentOptions < any , any , any , any > , 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 < any , any , any , any > , 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
1722 if ( ! Ctor . __decorators__ ) {
1823 Ctor . __decorators__ = [ ]
1924 }
0 commit comments