fix(closure): don't throw from top-level

workaround for http://b/27151095
This commit is contained in:
Alex Eagle 2016-03-08 12:23:57 -08:00
parent 0d58b137a7
commit 5824866a83
1 changed files with 7 additions and 3 deletions

View File

@ -238,9 +238,13 @@ export function Class(clsDef: ClassDefinition): ConcreteType {
} }
var Reflect = global.Reflect; 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)) { if (!(Reflect && Reflect.getMetadata)) {
throw 'reflect-metadata shim is required when using class decorators'; throw 'reflect-metadata shim is required when using class decorators';
} }
})();
export function makeDecorator( export function makeDecorator(
annotationCls, chainFn: (fn: Function) => void = null): (...args: any[]) => (cls: any) => any { annotationCls, chainFn: (fn: Function) => void = null): (...args: any[]) => (cls: any) => any {