fix(core): properly handle function without prototype in reflector (#22284)
closes #19978 PR Close #22284
This commit is contained in:
parent
b42921bbd2
commit
a7ebf5aadd
|
@ -252,7 +252,7 @@ function convertTsickleDecoratorIntoMetadata(decoratorInvocations: any[]): any[]
|
|||
}
|
||||
|
||||
function getParentCtor(ctor: Function): Type<any> {
|
||||
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.
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
Loading…
Reference in New Issue