fix(core): assigns an overriden name to constructor named constructor (#11043)

Fixes #10545
This commit is contained in:
Chuck Jazdzewski 2016-08-24 10:21:13 -07:00 committed by Kara
parent f1ce7607a6
commit bd510ccdbb
2 changed files with 6 additions and 1 deletions

View File

@ -243,7 +243,8 @@ export function Class(clsDef: ClassDefinition): Type<any> {
Reflect.defineMetadata('annotations', this.annotations, constructor);
}
if (!constructor['name']) {
const constructorName = constructor['name'];
if (!constructorName || constructorName === 'constructor') {
(constructor as any)['overriddenName'] = `class${_nextClassId++}`;
}

View File

@ -132,6 +132,10 @@ export function main() {
.toThrowError(
'Class definition \'extends\' property must be a constructor function was: non_type');
});
it('should assign an overridden name for anonymous constructor functions', () => {
expect((Class({constructor: function() {}}) as any).overriddenName).not.toBeUndefined();
});
});
});
});