diff --git a/modules/@angular/core/src/util/decorators.ts b/modules/@angular/core/src/util/decorators.ts index 61d6906257..754e344e63 100644 --- a/modules/@angular/core/src/util/decorators.ts +++ b/modules/@angular/core/src/util/decorators.ts @@ -240,7 +240,7 @@ export function Class(clsDef: ClassDefinition): Type { for (let key in clsDef) { if (key !== 'extends' && key !== 'prototype' && clsDef.hasOwnProperty(key)) { - proto[key] = applyParams(clsDef[key], key); + proto[key] = applyParams(clsDef[key], key); } } diff --git a/modules/@angular/core/test/util/decorators_spec.ts b/modules/@angular/core/test/util/decorators_spec.ts index a1725ab10a..2af359fa60 100644 --- a/modules/@angular/core/test/util/decorators_spec.ts +++ b/modules/@angular/core/test/util/decorators_spec.ts @@ -17,28 +17,28 @@ class DecoratedParent {} class DecoratedChild extends DecoratedParent {} export function main() { - var Reflect = global.Reflect; + const Reflect = global.Reflect; - var TerminalDecorator = makeDecorator('TerminalDecorator', {terminal: true}); - var TestDecorator = makeDecorator( + const TerminalDecorator = makeDecorator('TerminalDecorator', {terminal: true}); + const TestDecorator = makeDecorator( 'TestDecorator', {marker: undefined}, Object, (fn: any) => fn.Terminal = TerminalDecorator); describe('decorators', () => { it('should invoke as decorator', () => { function Type() {} TestDecorator({marker: 'WORKS'})(Type); - var annotations = Reflect.getMetadata('annotations', Type); + const annotations = Reflect.getMetadata('annotations', Type); expect(annotations[0].marker).toEqual('WORKS'); }); it('should invoke as new', () => { - var annotation = new (TestDecorator)({marker: 'WORKS'}); + const annotation = new (TestDecorator)({marker: 'WORKS'}); expect(annotation instanceof TestDecorator).toEqual(true); expect(annotation.marker).toEqual('WORKS'); }); it('should invoke as chain', () => { - var chain: any = TestDecorator({marker: 'WORKS'}); + let chain: any = TestDecorator({marker: 'WORKS'}); expect(typeof chain.Terminal).toEqual('function'); chain = chain.Terminal(); expect(chain.annotations[0] instanceof TestDecorator).toEqual(true); @@ -50,15 +50,16 @@ export function main() { TestDecorator({marker: 'parent'})(DecoratedParent); TestDecorator({marker: 'child'})(DecoratedChild); - var annotations = Reflect.getOwnMetadata('annotations', DecoratedChild); + const annotations = Reflect.getOwnMetadata('annotations', DecoratedChild); expect(annotations.length).toBe(1); expect(annotations[0].marker).toEqual('child'); }); describe('Class', () => { it('should create a class', () => { - var i0: any /** TODO #9100 */, i1: any /** TODO #9100 */; - var MyClass = (TestDecorator({marker: 'test-works'})).Class({ + let i0: any; + let i1: any; + const MyClass = (TestDecorator({marker: 'test-works'})).Class({ extends: Class({ constructor: function() {}, extendWorks: function() { return 'extend ' + this.arg; } @@ -71,14 +72,15 @@ export function main() { works: function() { return this.arg; }, prototype: 'IGNORE' }); - var obj: any = new MyClass('WORKS'); + + const obj: any = new MyClass('WORKS'); expect(obj.arg).toEqual('WORKS'); expect(obj.works()).toEqual('WORKS'); expect(obj.extendWorks()).toEqual('extend WORKS'); expect(reflector.parameters(MyClass)).toEqual([[String]]); expect(reflector.parameters(obj.methodA)).toEqual([[i0], [i1.annotation, Number]]); - var proto = (MyClass).prototype; + const proto = (MyClass).prototype; expect(proto.extends).toEqual(undefined); expect(proto.prototype).toEqual(undefined); @@ -115,13 +117,13 @@ export function main() { }); it('should ensure that only Function|Arrays are supported', () => { - expect(() => { Class({constructor: function() {}, method: 'non_function'}); }) + expect(() => { Class({constructor: function() {}, method: 'non_function'}); }) .toThrowError( 'Only Function or Array is supported in Class definition for key \'method\' is \'non_function\''); }); it('should ensure that extends is a Function', () => { - expect(() => { (Class)({extends: 'non_type', constructor: function() {}}); }) + expect(() => { Class({extends: 'non_type', constructor: function() {}}); }) .toThrowError( 'Class definition \'extends\' property must be a constructor function was: non_type'); });