X Tutup
Skip to content

Commit 5824866

Browse files
committed
fix(closure): don't throw from top-level
workaround for http://b/27151095
1 parent 0d58b13 commit 5824866

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

modules/angular2/src/core/util/decorators.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,13 @@ export function Class(clsDef: ClassDefinition): ConcreteType {
238238
}
239239

240240
var Reflect = global.Reflect;
241-
if (!(Reflect && Reflect.getMetadata)) {
242-
throw 'reflect-metadata shim is required when using class decorators';
243-
}
241+
// Throw statement at top-level is disallowed by closure compiler in ES6 input.
242+
// Wrap in an IIFE as a work-around.
243+
(function checkReflect() {
244+
if (!(Reflect && Reflect.getMetadata)) {
245+
throw 'reflect-metadata shim is required when using class decorators';
246+
}
247+
})();
244248

245249
export function makeDecorator(
246250
annotationCls, chainFn: (fn: Function) => void = null): (...args: any[]) => (cls: any) => any {

0 commit comments

Comments
 (0)
X Tutup