From 5824866a8331f4ff52ffb6617741a8c0c1f09f5a Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Tue, 8 Mar 2016 12:23:57 -0800 Subject: [PATCH] fix(closure): don't throw from top-level workaround for http://b/27151095 --- modules/angular2/src/core/util/decorators.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/angular2/src/core/util/decorators.ts b/modules/angular2/src/core/util/decorators.ts index 54f50fa565..6e54ec84f7 100644 --- a/modules/angular2/src/core/util/decorators.ts +++ b/modules/angular2/src/core/util/decorators.ts @@ -238,9 +238,13 @@ export function Class(clsDef: ClassDefinition): ConcreteType { } var Reflect = global.Reflect; -if (!(Reflect && Reflect.getMetadata)) { - throw 'reflect-metadata shim is required when using class decorators'; -} +// 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, chainFn: (fn: Function) => void = null): (...args: any[]) => (cls: any) => any {