fix(core): assigns an overriden name to constructor named constructor (#11043)
Fixes #10545
This commit is contained in:
parent
f1ce7607a6
commit
bd510ccdbb
|
@ -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++}`;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue