fix(build): add missing return types now enforced by linter

This commit is contained in:
Alex Eagle
2015-06-26 11:10:52 -07:00
parent bc585f2724
commit 44891996b5
61 changed files with 467 additions and 400 deletions

View File

@ -14,7 +14,7 @@ export class BaseQueryList<T> {
protected _callbacks = [];
protected _dirty = false;
[Symbol.iterator]() { return this._results[Symbol.iterator](); }
[Symbol.iterator](): any { return this._results[Symbol.iterator](); }
reset(newList) {
this._results = newList;
@ -33,9 +33,9 @@ export class BaseQueryList<T> {
}
}
onChange(callback) { this._callbacks.push(callback); }
onChange(callback): void { this._callbacks.push(callback); }
removeCallback(callback) { ListWrapper.remove(this._callbacks, callback); }
removeCallback(callback): void { ListWrapper.remove(this._callbacks, callback); }
get length() { return this._results.length; }
get first() { return ListWrapper.first(this._results); }

View File

@ -19,11 +19,11 @@ export class ElementBinder {
}
}
hasStaticComponent() {
hasStaticComponent(): boolean {
return isPresent(this.componentDirective) && isPresent(this.nestedProtoView);
}
hasEmbeddedProtoView() {
hasEmbeddedProtoView(): boolean {
return !isPresent(this.componentDirective) && isPresent(this.nestedProtoView);
}
}

View File

@ -190,11 +190,13 @@ export class DirectiveDependency extends Dependency {
}
static _attributeName(properties): string {
var p = ListWrapper.find(properties, (p) => p instanceof Attribute);
var p = <Attribute>ListWrapper.find(properties, (p) => p instanceof Attribute);
return isPresent(p) ? p.attributeName : null;
}
static _query(properties) { return ListWrapper.find(properties, (p) => p instanceof Query); }
static _query(properties): Query {
return <Query>ListWrapper.find(properties, (p) => p instanceof Query);
}
}
export class DirectiveBinding extends ResolvedBinding {
@ -292,7 +294,7 @@ export class PreBuiltObjects {
export class EventEmitterAccessor {
constructor(public eventName: string, public getter: Function) {}
subscribe(view: viewModule.AppView, boundElementIndex: number, directive: Object) {
subscribe(view: viewModule.AppView, boundElementIndex: number, directive: Object): Object {
var eventEmitter = this.getter(directive);
return ObservableWrapper.subscribe(
eventEmitter,
@ -303,7 +305,7 @@ export class EventEmitterAccessor {
export class HostActionAccessor {
constructor(public methodName: string, public getter: Function) {}
subscribe(view: viewModule.AppView, boundElementIndex: number, directive: Object) {
subscribe(view: viewModule.AppView, boundElementIndex: number, directive: Object): Object {
var eventEmitter = this.getter(directive);
return ObservableWrapper.subscribe(
eventEmitter,
@ -314,9 +316,9 @@ export class HostActionAccessor {
export class BindingData {
constructor(public binding: ResolvedBinding, public visibility: number) {}
getKeyId() { return this.binding.key.id; }
getKeyId(): number { return this.binding.key.id; }
createEventEmitterAccessors() {
createEventEmitterAccessors(): List<EventEmitterAccessor> {
if (!(this.binding instanceof DirectiveBinding)) return [];
var db = <DirectiveBinding>this.binding;
return ListWrapper.map(db.eventEmitters, eventConfig => {
@ -331,11 +333,11 @@ export class BindingData {
// short format: 'name' when fieldName and eventName are the same
fieldName = eventName = eventConfig;
}
return new EventEmitterAccessor(eventName, reflector.getter(fieldName))
return new EventEmitterAccessor(eventName, reflector.getter(fieldName));
});
}
createHostActionAccessors() {
createHostActionAccessors(): HostActionAccessor[] {
if (!(this.binding instanceof DirectiveBinding)) return [];
var res = [];
var db = <DirectiveBinding>this.binding;
@ -355,7 +357,7 @@ export class ProtoElementInjector {
static create(parent: ProtoElementInjector, index: number, bindings: List<ResolvedBinding>,
firstBindingIsComponent: boolean, distanceToParent: number,
directiveVariableBindings: Map<string, number>) {
directiveVariableBindings: Map<string, number>): ProtoElementInjector {
var bd = [];
ProtoElementInjector._createDirectiveBindingData(bindings, bd, firstBindingIsComponent);
@ -808,7 +810,7 @@ export class ElementInjector extends TreeNode<ElementInjector> {
}
}
getDirectiveAtIndex(index: number) { return this._injector.getObjAtIndex(index); }
getDirectiveAtIndex(index: number): any { return this._injector.getObjAtIndex(index); }
hasInstances(): boolean { return this._proto.hasBindings && this.hydrated; }

View File

@ -286,12 +286,14 @@ function _collectNestedProtoViewsVariableNames(
return nestedPvVariableNames;
}
function _createVariableNames(parentVariableNames, renderProtoView): List<string> {
var res = isBlank(parentVariableNames) ? [] : ListWrapper.clone(parentVariableNames);
function _createVariableNames(parentVariableNames: List<string>, renderProtoView): List<string> {
var res =
isBlank(parentVariableNames) ? <List<string>>[] : ListWrapper.clone(parentVariableNames);
MapWrapper.forEach(renderProtoView.variableBindings,
(mappedName, varName) => { res.push(mappedName); });
ListWrapper.forEach(renderProtoView.elementBinders, binder => {
MapWrapper.forEach(binder.variableBindings, (mappedName, varName) => { res.push(mappedName); });
MapWrapper.forEach(binder.variableBindings,
(mappedName: string, varName: string) => { res.push(mappedName); });
});
return res;
}

View File

@ -78,9 +78,9 @@ import {BaseQueryList} from './base_query_list';
export class QueryList<T> extends BaseQueryList<T> {
/**
*/
onChange(callback) { return super.onChange(callback); }
onChange(callback) { super.onChange(callback); }
/**
*/
removeCallback(callback) { return super.removeCallback(callback); }
removeCallback(callback) { super.removeCallback(callback); }
}

View File

@ -134,12 +134,12 @@ export class AppView implements ChangeDispatcher, EventDispatcher {
}
}
getDirectiveFor(directive: DirectiveIndex) {
getDirectiveFor(directive: DirectiveIndex): any {
var elementInjector = this.elementInjectors[directive.elementIndex];
return elementInjector.getDirectiveAtIndex(directive.directiveIndex);
}
getDetectorFor(directive: DirectiveIndex) {
getDetectorFor(directive: DirectiveIndex): any {
var childView = this.componentChildViews[directive.elementIndex];
return isPresent(childView) ? childView.changeDetector : null;
}

View File

@ -42,7 +42,9 @@ export class ViewContainerRef {
return this.viewManager.attachViewInContainer(this.element, atIndex, viewRef);
}
indexOf(viewRef: ViewRef) { return ListWrapper.indexOf(this._getViews(), internalView(viewRef)); }
indexOf(viewRef: ViewRef): number {
return ListWrapper.indexOf(this._getViews(), internalView(viewRef));
}
remove(atIndex: number = -1): void {
if (atIndex == -1) atIndex = this.length - 1;