fix(core): don't require reflect-metadata shim when in AOT mode

This commit is contained in:
Igor Minar 2016-08-31 11:12:07 -07:00 committed by Martin Probst
parent cc89ef6c8c
commit f4f6f4b4d8
1 changed files with 4 additions and 7 deletions

View File

@ -252,17 +252,14 @@ export function Class(clsDef: ClassDefinition): Type<any> {
}
var Reflect = global.Reflect;
// Throw statement at top-level is disallowed by closure compiler in ES6 input.
// Wrap in an IIFE as a work-around.
(function checkReflect() {
if (!(Reflect && Reflect.getMetadata)) {
throw 'reflect-metadata shim is required when using class decorators';
}
})();
export function makeDecorator(annotationCls: any, chainFn: (fn: Function) => void = null):
(...args: any[]) => (cls: any) => any {
function DecoratorFactory(objOrType: any): (cls: any) => any {
if (!(Reflect && Reflect.getMetadata)) {
throw 'reflect-metadata shim is required when using class decorators';
}
const annotationInstance = new (<any>annotationCls)(objOrType);
if (this instanceof annotationCls) {
return annotationInstance;