From f4f6f4b4d89c1bfe9112620facb8ee33b2a9ca68 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 31 Aug 2016 11:12:07 -0700 Subject: [PATCH] fix(core): don't require reflect-metadata shim when in AOT mode --- modules/@angular/core/src/util/decorators.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/@angular/core/src/util/decorators.ts b/modules/@angular/core/src/util/decorators.ts index a9fcee2836..d9a7608c5d 100644 --- a/modules/@angular/core/src/util/decorators.ts +++ b/modules/@angular/core/src/util/decorators.ts @@ -252,17 +252,14 @@ export function Class(clsDef: ClassDefinition): Type { } 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 (annotationCls)(objOrType); if (this instanceof annotationCls) { return annotationInstance;