diff --git a/modules/@angular/core/src/metadata/lifecycle_hooks.ts b/modules/@angular/core/src/metadata/lifecycle_hooks.ts index 81597293df..7423e0c8e7 100644 --- a/modules/@angular/core/src/metadata/lifecycle_hooks.ts +++ b/modules/@angular/core/src/metadata/lifecycle_hooks.ts @@ -86,9 +86,7 @@ export var LIFECYCLE_HOOKS_VALUES = [ * ``` * @stable */ -export abstract class OnChanges { - abstract ngOnChanges(changes: SimpleChanges): any /** TODO #9100 */; -} +export abstract class OnChanges { abstract ngOnChanges(changes: SimpleChanges): void; } /** * Implement this interface to execute custom initialization logic after your directive's @@ -132,7 +130,7 @@ export abstract class OnChanges { * ``` * @stable */ -export abstract class OnInit { abstract ngOnInit(): any /** TODO #9100 */; } +export abstract class OnInit { abstract ngOnInit(): void; } /** * Implement this interface to supplement the default change detection algorithm in your directive. @@ -201,7 +199,7 @@ export abstract class OnInit { abstract ngOnInit(): any /** TODO #9100 */; } * ``` * @stable */ -export abstract class DoCheck { abstract ngDoCheck(): any /** TODO #9100 */; } +export abstract class DoCheck { abstract ngDoCheck(): void; } /** * Implement this interface to get notified when your directive is destroyed. @@ -293,7 +291,7 @@ export abstract class DoCheck { abstract ngDoCheck(): any /** TODO #9100 */; } * * @stable */ -export abstract class OnDestroy { abstract ngOnDestroy(): any /** TODO #9100 */; } +export abstract class OnDestroy { abstract ngOnDestroy(): void; } /** * Implement this interface to get notified when your directive's content has been fully @@ -347,7 +345,7 @@ export abstract class OnDestroy { abstract ngOnDestroy(): any /** TODO #9100 */; * ``` * @stable */ -export abstract class AfterContentInit { abstract ngAfterContentInit(): any /** TODO #9100 */; } +export abstract class AfterContentInit { abstract ngAfterContentInit(): void; } /** * Implement this interface to get notified after every check of your directive's content. @@ -396,9 +394,7 @@ export abstract class AfterContentInit { abstract ngAfterContentInit(): any /** * ``` * @stable */ -export abstract class AfterContentChecked { - abstract ngAfterContentChecked(): any /** TODO #9100 */; -} +export abstract class AfterContentChecked { abstract ngAfterContentChecked(): void; } /** * Implement this interface to get notified when your component's view has been fully initialized. @@ -446,7 +442,7 @@ export abstract class AfterContentChecked { * ``` * @stable */ -export abstract class AfterViewInit { abstract ngAfterViewInit(): any /** TODO #9100 */; } +export abstract class AfterViewInit { abstract ngAfterViewInit(): void; } /** * Implement this interface to get notified after every check of your component's view. @@ -497,4 +493,4 @@ export abstract class AfterViewInit { abstract ngAfterViewInit(): any /** TODO # * ``` * @stable */ -export abstract class AfterViewChecked { abstract ngAfterViewChecked(): any /** TODO #9100 */; } +export abstract class AfterViewChecked { abstract ngAfterViewChecked(): void; } diff --git a/modules/@angular/core/src/util/decorators.ts b/modules/@angular/core/src/util/decorators.ts index 40adba0515..49a2bb38f0 100644 --- a/modules/@angular/core/src/util/decorators.ts +++ b/modules/@angular/core/src/util/decorators.ts @@ -103,24 +103,24 @@ function applyParams(fnOrArray: (Function | any[]), key: string): Function { if (isFunction(fnOrArray)) { return fnOrArray; } else if (fnOrArray instanceof Array) { - var annotations: any[] = fnOrArray; - var fn: Function = fnOrArray[fnOrArray.length - 1]; + const annotations: any[] = fnOrArray; + const annoLength = annotations.length - 1; + const fn: Function = fnOrArray[annoLength]; if (!isFunction(fn)) { throw new Error( `Last position of Class method array must be Function in key ${key} was '${stringify(fn)}'`); } - var annoLength = annotations.length - 1; if (annoLength != fn.length) { throw new Error( `Number of annotations (${annoLength}) does not match number of arguments (${fn.length}) in the function: ${stringify(fn)}`); } - var paramsAnnotations: any[][] = []; - for (var i = 0, ii = annotations.length - 1; i < ii; i++) { - var paramAnnotations: any[] = []; + const paramsAnnotations: any[][] = []; + for (let i = 0, ii = annotations.length - 1; i < ii; i++) { + const paramAnnotations: any[] = []; paramsAnnotations.push(paramAnnotations); - var annotation = annotations[i]; + const annotation = annotations[i]; if (annotation instanceof Array) { - for (var j = 0; j < annotation.length; j++) { + for (let j = 0; j < annotation.length; j++) { paramAnnotations.push(extractAnnotation(annotation[j])); } } else if (isFunction(annotation)) { @@ -220,9 +220,9 @@ function applyParams(fnOrArray: (Function | any[]), key: string): Function { * @stable */ export function Class(clsDef: ClassDefinition): ConcreteType { - var constructor = applyParams( + const constructor = applyParams( clsDef.hasOwnProperty('constructor') ? clsDef.constructor : undefined, 'constructor'); - var proto = constructor.prototype; + let proto = constructor.prototype; if (clsDef.hasOwnProperty('extends')) { if (isFunction(clsDef.extends)) { (constructor).prototype = proto = @@ -232,7 +232,7 @@ export function Class(clsDef: ClassDefinition): ConcreteType { `Class definition 'extends' property must be a constructor function was: ${stringify(clsDef.extends)}`); } } - for (var key in clsDef) { + for (let key in clsDef) { if (key != 'extends' && key != 'prototype' && clsDef.hasOwnProperty(key)) { proto[key] = applyParams(clsDef[key], key); } @@ -243,7 +243,7 @@ export function Class(clsDef: ClassDefinition): ConcreteType { } if (!constructor['name']) { - (constructor as any /** TODO #9100 */)['overriddenName'] = `class${_nextClassId++}`; + (constructor as any)['overriddenName'] = `class${_nextClassId++}`; } return >constructor; @@ -258,25 +258,22 @@ var Reflect = global.Reflect; } })(); -export function makeDecorator( - annotationCls: any /* TODO #9100 */, - chainFn: (fn: Function) => void = null): (...args: any[]) => (cls: any) => any { - function DecoratorFactory(objOrType: any /** TODO #9100 */): (cls: any) => any { - var annotationInstance = new (annotationCls)(objOrType); +export function makeDecorator(annotationCls: any, chainFn: (fn: Function) => void = null): + (...args: any[]) => (cls: any) => any { + function DecoratorFactory(objOrType: any): (cls: any) => any { + const annotationInstance = new (annotationCls)(objOrType); if (this instanceof annotationCls) { return annotationInstance; } else { - var chainAnnotation = + const chainAnnotation = isFunction(this) && this.annotations instanceof Array ? this.annotations : []; chainAnnotation.push(annotationInstance); - var TypeDecorator: TypeDecorator = - function TypeDecorator(cls: any /** TODO #9100 */) { - var annotations = Reflect.getOwnMetadata('annotations', cls); - annotations = annotations || []; - annotations.push(annotationInstance); - Reflect.defineMetadata('annotations', annotations, cls); - return cls; - }; + const TypeDecorator: TypeDecorator = function TypeDecorator(cls: Type) { + const annotations = Reflect.getOwnMetadata('annotations', cls) || []; + annotations.push(annotationInstance); + Reflect.defineMetadata('annotations', annotations, cls); + return cls; + }; TypeDecorator.annotations = chainAnnotation; TypeDecorator.Class = Class; if (chainFn) chainFn(TypeDecorator); @@ -288,8 +285,8 @@ export function makeDecorator( return DecoratorFactory; } -export function makeParamDecorator(annotationCls: any /** TODO #9100 */): any { - function ParamDecoratorFactory(...args: any[] /** TODO #9100 */): any { +export function makeParamDecorator(annotationCls: any): any { + function ParamDecoratorFactory(...args: any[]): any { var annotationInstance = Object.create(annotationCls.prototype); annotationCls.apply(annotationInstance, args); if (this instanceof annotationCls) { @@ -300,11 +297,8 @@ export function makeParamDecorator(annotationCls: any /** TODO #9100 */): any { } - function ParamDecorator( - cls: any /** TODO #9100 */, unusedKey: any /** TODO #9100 */, - index: any /** TODO #9100 */): any { - var parameters: any[][] = Reflect.getMetadata('parameters', cls); - parameters = parameters || []; + function ParamDecorator(cls: any, unusedKey: any, index: number): any { + const parameters: any[][] = Reflect.getMetadata('parameters', cls) || []; // there might be gaps if some in between parameters do not have annotations. // we pad with nulls. @@ -325,8 +319,8 @@ export function makeParamDecorator(annotationCls: any /** TODO #9100 */): any { return ParamDecoratorFactory; } -export function makePropDecorator(annotationCls: any /** TODO #9100 */): any { - function PropDecoratorFactory(...args: any[] /** TODO #9100 */): any { +export function makePropDecorator(annotationCls: any): any { + function PropDecoratorFactory(...args: any[]): any { var decoratorInstance = Object.create(annotationCls.prototype); annotationCls.apply(decoratorInstance, args); @@ -334,8 +328,7 @@ export function makePropDecorator(annotationCls: any /** TODO #9100 */): any { return decoratorInstance; } else { return function PropDecorator(target: any, name: string) { - var meta = Reflect.getOwnMetadata('propMetadata', target.constructor); - meta = meta || {}; + const meta = Reflect.getOwnMetadata('propMetadata', target.constructor) || {}; meta[name] = meta[name] || []; meta[name].unshift(decoratorInstance); Reflect.defineMetadata('propMetadata', meta, target.constructor); diff --git a/tools/public_api_guard/core/index.d.ts b/tools/public_api_guard/core/index.d.ts index ee4e59b9c9..3a68256e3c 100644 --- a/tools/public_api_guard/core/index.d.ts +++ b/tools/public_api_guard/core/index.d.ts @@ -7,22 +7,22 @@ export declare class AbstractProviderError extends BaseException { /** @stable */ export declare abstract class AfterContentChecked { - abstract ngAfterContentChecked(): any; + abstract ngAfterContentChecked(): void; } /** @stable */ export declare abstract class AfterContentInit { - abstract ngAfterContentInit(): any; + abstract ngAfterContentInit(): void; } /** @stable */ export declare abstract class AfterViewChecked { - abstract ngAfterViewChecked(): any; + abstract ngAfterViewChecked(): void; } /** @stable */ export declare abstract class AfterViewInit { - abstract ngAfterViewInit(): any; + abstract ngAfterViewInit(): void; } /** @experimental */ @@ -686,7 +686,7 @@ export declare function disposePlatform(): void; /** @stable */ export declare abstract class DoCheck { - abstract ngDoCheck(): any; + abstract ngDoCheck(): void; } /** @deprecated */ @@ -972,17 +972,17 @@ export declare class NoProviderError extends AbstractProviderError { /** @stable */ export declare abstract class OnChanges { - abstract ngOnChanges(changes: SimpleChanges): any; + abstract ngOnChanges(changes: SimpleChanges): void; } /** @stable */ export declare abstract class OnDestroy { - abstract ngOnDestroy(): any; + abstract ngOnDestroy(): void; } /** @stable */ export declare abstract class OnInit { - abstract ngOnInit(): any; + abstract ngOnInit(): void; } /** @stable */