Skip to content

Commit

Permalink
fix(core): Assigns an overriden name to constructor named constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
chuckjaz committed Aug 24, 2016
1 parent 14a30f3 commit 9b5534a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/@angular/core/src/util/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++}`;
}

Expand Down
4 changes: 4 additions & 0 deletions modules/@angular/core/test/util/decorators_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 annonymous constructor functions', () => {
expect((Class({constructor: function() {}}) as any).overriddenName).not.toBeUndefined();
});
});
});
});
Expand Down

0 comments on commit 9b5534a

Please sign in to comment.