1- Object . defineProperty ( exports , '__esModule' , {
2- value : true
3- } )
1+ import * as Vue from 'vue'
42
5- var Vue = require ( 'vue' )
6-
7- var internalHooks = [
3+ const internalHooks = [
84 'data' ,
95 'beforeCreate' ,
106 'created' ,
@@ -19,13 +15,15 @@ var internalHooks = [
1915 'render'
2016]
2117
22- function componentFactory ( Component , options ) {
23- if ( ! options ) {
24- options = { }
25- }
26- options . name = options . name || Component . name
18+ export type VueClass = { new ( ) : Vue } & typeof Vue
19+
20+ function componentFactory (
21+ Component : VueClass ,
22+ options : Vue . ComponentOptions < any > = { }
23+ ) : VueClass {
24+ options . name = options . name || ( Component as any ) . _componentTag
2725 // prototype props.
28- var proto = Component . prototype
26+ const proto = Component . prototype
2927 Object . getOwnPropertyNames ( proto ) . forEach ( function ( key ) {
3028 if ( key === 'constructor' ) {
3129 return
@@ -35,7 +33,7 @@ function componentFactory (Component, options) {
3533 options [ key ] = proto [ key ]
3634 return
3735 }
38- var descriptor = Object . getOwnPropertyDescriptor ( proto , key )
36+ const descriptor = Object . getOwnPropertyDescriptor ( proto , key )
3937 if ( typeof descriptor . value === 'function' ) {
4038 // methods
4139 ( options . methods || ( options . methods = { } ) ) [ key ] = descriptor . value
@@ -48,20 +46,21 @@ function componentFactory (Component, options) {
4846 }
4947 } )
5048 // find super
51- var superProto = Object . getPrototypeOf ( Component . prototype )
52- var Super = superProto instanceof Vue
53- ? superProto . constructor
49+ const superProto = Object . getPrototypeOf ( Component . prototype )
50+ const Super : VueClass = superProto instanceof Vue
51+ ? superProto . constructor as VueClass
5452 : Vue
5553 return Super . extend ( options )
5654}
5755
58- function decorator ( options ) {
56+ export default function decorator ( options : Vue . ComponentOptions < any > ) : < V extends VueClass > ( target : V ) => V
57+ export default function decorator < V extends VueClass > ( target : V ) : V
58+ export default function decorator < V extends VueClass > ( options : Vue . ComponentOptions < any > | V ) : any {
5959 if ( typeof options === 'function' ) {
6060 return componentFactory ( options )
6161 }
62- return function ( Component ) {
62+ return function ( Component : any ) {
6363 return componentFactory ( Component , options )
6464 }
6565}
6666
67- exports . default = decorator
0 commit comments