1
- import core from 'core-js' ;
1
+ import * as core from 'core-js' ;
2
2
3
3
const theGlobal = ( function ( ) {
4
4
// Workers don’t have `window`, only `self`
@@ -38,7 +38,7 @@ if(typeof theGlobal.Reflect.getOwnMetadata === 'undefined'){
38
38
39
39
if ( typeof theGlobal . Reflect . defineMetadata === 'undefined' ) {
40
40
Reflect . defineMetadata = function ( metadataKey , metadataValue , target , targetKey ) {
41
- var metadataContainer = target [ metadataContainerKey ] || ( target [ metadataContainerKey ] = { } ) ;
41
+ var metadataContainer = target . hasOwnProperty ( metadataContainerKey ) ? target [ metadataContainerKey ] : ( target [ metadataContainerKey ] = { } ) ;
42
42
var targetContainer = metadataContainer [ targetKey ] || ( metadataContainer [ targetKey ] = { } ) ;
43
43
targetContainer [ metadataKey ] = metadataValue ;
44
44
} ;
@@ -69,26 +69,33 @@ function ensureDecorators(target){
69
69
}
70
70
}
71
71
72
+ interface MetadataType {
73
+ global: Object ;
74
+ resource:string ;
75
+ paramTypes:string ;
76
+ properties:string ;
77
+ }
78
+
72
79
/**
73
80
* Provides helpers for working with metadata.
74
81
*
75
82
* @class Metadata
76
83
* @static
77
84
*/
78
- export var Metadata = {
85
+ export var Metadata : MetadataType = {
79
86
global : theGlobal ,
80
87
resource :'aurelia:resource' ,
81
88
paramTypes :'design:paramtypes' ,
82
89
properties :'design:properties' ,
83
- get ( metadataKey : string , target : Function , targetKey : string ) {
90
+ get ( metadataKey : string , target : Function , targetKey : string ) : Object {
84
91
if ( ! target ) {
85
92
return undefined ;
86
93
}
87
94
88
95
let result = Metadata . getOwn ( metadataKey , target , targetKey ) ;
89
96
return result === undefined ? Metadata . get ( metadataKey , Object . getPrototypeOf ( target ) , targetKey ) : result ;
90
97
} ,
91
- getOwn ( metadataKey : string , target : Function , targetKey : string ) {
98
+ getOwn ( metadataKey : string , target : Function , targetKey : string ) : Object {
92
99
if ( ! target ) {
93
100
return undefined ;
94
101
}
@@ -99,10 +106,10 @@ export var Metadata = {
99
106
100
107
return Reflect . getOwnMetadata ( metadataKey , target , targetKey ) ;
101
108
} ,
102
- define ( metadataKey : string , metadataValue : string , target : Function , targetKey : string ) {
109
+ define ( metadataKey : string , metadataValue : Object , target : Function , targetKey : string ) : void {
103
110
Reflect. defineMetadata ( metadataKey , metadataValue , target , targetKey ) ;
104
111
} ,
105
- getOrCreateOwn ( metadataKey : string , Type : Function , target : Function , targetKey : string ) {
112
+ getOrCreateOwn ( metadataKey : string , Type : Function , target : Function , targetKey : string ) : Object {
106
113
let result = Metadata . getOwn ( metadataKey , target , targetKey ) ;
107
114
108
115
if ( result === undefined ) {
@@ -114,7 +121,7 @@ export var Metadata = {
114
121
}
115
122
}
116
123
117
- var originStorage = new Map ( ) ,
124
+ let originStorage = new Map ( ) ,
118
125
unknownOrigin = Object . freeze ( { moduleId :undefined , moduleMember :undefined } ) ;
119
126
120
127
/**
@@ -126,7 +133,7 @@ var originStorage = new Map(),
126
133
* @param {string } moduleMember The name of the export in the origin module.
127
134
*/
128
135
export class Origin {
129
- constructor ( moduleId : string , moduleMember : string ) {
136
+ constructor ( moduleId : string , moduleMember : string ) {
130
137
this . moduleId = moduleId ;
131
138
this . moduleMember = moduleMember ;
132
139
}
@@ -139,7 +146,7 @@ export class Origin {
139
146
* @param {Function } fn The function to inspect for Origin metadata.
140
147
* @return {Origin } Returns the Origin metadata.
141
148
*/
142
- static get ( fn : Function ) {
149
+ static get ( fn : Function ) : Origin {
143
150
var origin = originStorage . get ( fn ) ;
144
151
145
152
if ( origin === undefined ) {
@@ -171,7 +178,7 @@ export class Origin {
171
178
* @param {origin } fn The Origin metadata to store on the function.
172
179
* @return {Origin } Returns the Origin metadata.
173
180
*/
174
- static set ( fn : Function , origin : Origin ) {
181
+ static set ( fn : Function , origin : Origin ) : void {
175
182
originStorage . set ( fn , origin ) ;
176
183
}
177
184
}
@@ -184,7 +191,7 @@ export class DecoratorApplicator {
184
191
this . _rest = null ;
185
192
}
186
193
187
- decorator ( decorator : Function ) : DecoratorApplicator {
194
+ decorator ( decorator : Function ) : DecoratorApplicator {
188
195
if ( this . _first === null ) {
189
196
this . _first = decorator ;
190
197
return this ;
@@ -209,7 +216,7 @@ export class DecoratorApplicator {
209
216
return this ;
210
217
}
211
218
212
- _decorate ( target : Function ) {
219
+ _decorate ( target : Function ) : void {
213
220
var i , ii , rest ;
214
221
215
222
if ( this . _first !== null ) {
@@ -233,9 +240,17 @@ export class DecoratorApplicator {
233
240
}
234
241
}
235
242
236
- export var Decorators = {
243
+ interface DecoratorsConfigType {
244
+
245
+ }
246
+
247
+ interface DecoratorsType {
248
+ configure : DecoratorsConfigType ;
249
+ }
250
+
251
+ export let Decorators : DecoratorsType = {
237
252
configure : {
238
- parameterizedDecorator ( name : string , decorator : Function ) {
253
+ parameterizedDecorator ( name : string , decorator : Function ) : void {
239
254
Decorators[ name ] = function ( ) {
240
255
var applicator = new DecoratorApplicator ( ) ;
241
256
return applicator [ name ] . apply ( applicator , arguments ) ;
@@ -246,7 +261,7 @@ export var Decorators = {
246
261
return this . decorator ( result ) ;
247
262
} ;
248
263
} ,
249
- simpleDecorator ( name : string , decorator : Function ) {
264
+ simpleDecorator ( name : string , decorator : Function ) : void {
250
265
Decorators[ name ] = function ( ) {
251
266
return new DecoratorApplicator ( ) . decorator ( decorator ) ;
252
267
} ;
0 commit comments