diff --git a/packages/core/src/reflection/reflection_capabilities.ts b/packages/core/src/reflection/reflection_capabilities.ts index 1e6123e7de..70d67a5cf9 100644 --- a/packages/core/src/reflection/reflection_capabilities.ts +++ b/packages/core/src/reflection/reflection_capabilities.ts @@ -252,7 +252,7 @@ function convertTsickleDecoratorIntoMetadata(decoratorInvocations: any[]): any[] } function getParentCtor(ctor: Function): Type { - const parentProto = Object.getPrototypeOf(ctor.prototype); + const parentProto = ctor.prototype ? Object.getPrototypeOf(ctor.prototype) : null; const parentCtor = parentProto ? parentProto.constructor : null; // Note: We always use `Object` as the null value // to simplify checking later on. diff --git a/packages/core/test/reflection/reflector_spec.ts b/packages/core/test/reflection/reflector_spec.ts index 0ca80cd81a..7c77e5033a 100644 --- a/packages/core/test/reflection/reflector_spec.ts +++ b/packages/core/test/reflection/reflector_spec.ts @@ -181,6 +181,13 @@ class TestObj { expect(DELEGATE_CTOR.exec(ChildNoCtorPrivateProps.toString())).toBeTruthy(); expect(DELEGATE_CTOR.exec(ChildWithCtor.toString())).toBeFalsy(); }); + + it('should not throw when no prototype on type', () => { + // Cannot test arrow function here due to the compilation + const dummyArrowFn = function() {}; + Object.defineProperty(dummyArrowFn, 'prototype', {value: undefined}); + expect(() => reflector.annotations(dummyArrowFn as any)).not.toThrow(); + }); }); describe('inheritance with decorators', () => {