From f7f06c5ad4ccefd0f156adce9d0570277b9417c6 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sun, 19 Apr 2015 14:47:02 -0700 Subject: [PATCH] chore: add more type annotations --- .../src/change_detection/parser/ast.js | 8 +++--- .../src/change_detection/parser/locals.js | 4 +-- modules/angular2/src/core/annotations/view.js | 6 ++-- .../angular2/src/core/application_tokens.js | 10 +++---- .../angular2/src/core/compiler/compiler.js | 12 ++++---- .../core/compiler/dynamic_component_loader.js | 2 +- .../src/core/compiler/element_injector.js | 18 ++++++------ .../angular2/src/core/compiler/ng_element.js | 2 +- modules/angular2/src/core/compiler/view.js | 26 ++++++++--------- .../src/core/compiler/view_container.js | 28 +++++++++---------- modules/angular2/src/di/exceptions.js | 12 ++++---- modules/angular2/src/di/injector.js | 15 +++++----- modules/angular2/src/di/opaque_token.js | 2 +- modules/angular2/src/directives/class.js | 2 +- modules/angular2/src/directives/if.js | 2 +- modules/angular2/src/directives/switch.js | 10 +++---- modules/angular2/src/dom/dom_adapter.js | 2 +- 17 files changed, 80 insertions(+), 81 deletions(-) diff --git a/modules/angular2/src/change_detection/parser/ast.js b/modules/angular2/src/change_detection/parser/ast.js index c2541cec32..988ec6016f 100644 --- a/modules/angular2/src/change_detection/parser/ast.js +++ b/modules/angular2/src/change_detection/parser/ast.js @@ -6,7 +6,7 @@ export class AST { throw new BaseException("Not supported"); } - get isAssignable() { + get isAssignable():boolean { return false; } @@ -113,7 +113,7 @@ export class AccessMember extends AST { } } - get isAssignable() { + get isAssignable():boolean { return true; } @@ -148,7 +148,7 @@ export class KeyedAccess extends AST { return obj[key]; } - get isAssignable() { + get isAssignable():boolean { return true; } @@ -397,7 +397,7 @@ export class ASTWithSource extends AST { return this.ast.eval(context, locals); } - get isAssignable() { + get isAssignable():boolean { return this.ast.isAssignable; } diff --git a/modules/angular2/src/change_detection/parser/locals.js b/modules/angular2/src/change_detection/parser/locals.js index 7298d29008..7911213030 100644 --- a/modules/angular2/src/change_detection/parser/locals.js +++ b/modules/angular2/src/change_detection/parser/locals.js @@ -34,7 +34,7 @@ export class Locals { throw new BaseException(`Cannot find '${name}'`); } - set(name:string, value) { + set(name:string, value):void { // TODO(rado): consider removing this check if we can guarantee this is not // exposed to the public API. // TODO: vsavkin maybe it should check only the local map @@ -45,7 +45,7 @@ export class Locals { } } - clearValues() { + clearValues():void { MapWrapper.clearValues(this.current); } } \ No newline at end of file diff --git a/modules/angular2/src/core/annotations/view.js b/modules/angular2/src/core/annotations/view.js index 2ceecabc60..3eb8e04319 100644 --- a/modules/angular2/src/core/annotations/view.js +++ b/modules/angular2/src/core/annotations/view.js @@ -38,14 +38,14 @@ export class View { * * NOTE: either `templateURL` or `template` should be used, but not both. */ - templateUrl:any; //string; + templateUrl:string; /** * Specifies an inline template for an angular component. * * NOTE: either `templateURL` or `template` should be used, but not both. */ - template:any; //string; + template:string; /** * Specifies a list of directives that can be used within a template. @@ -69,7 +69,7 @@ export class View { * } * ``` */ - directives:any; //List; + directives:List; /** * Specify a custom renderer for this View. diff --git a/modules/angular2/src/core/application_tokens.js b/modules/angular2/src/core/application_tokens.js index 0850a1b085..c14a620dd1 100644 --- a/modules/angular2/src/core/application_tokens.js +++ b/modules/angular2/src/core/application_tokens.js @@ -1,7 +1,7 @@ import {OpaqueToken} from 'angular2/di'; -export var appComponentRefToken = new OpaqueToken('ComponentRef'); -export var appChangeDetectorToken = new OpaqueToken('AppChangeDetector'); -export var appElementToken = new OpaqueToken('AppElement'); -export var appComponentAnnotatedTypeToken = new OpaqueToken('AppComponentAnnotatedType'); -export var appDocumentToken = new OpaqueToken('AppDocument'); +export var appComponentRefToken:OpaqueToken = new OpaqueToken('ComponentRef'); +export var appChangeDetectorToken:OpaqueToken = new OpaqueToken('AppChangeDetector'); +export var appElementToken:OpaqueToken = new OpaqueToken('AppElement'); +export var appComponentAnnotatedTypeToken:OpaqueToken = new OpaqueToken('AppComponentAnnotatedType'); +export var appDocumentToken:OpaqueToken = new OpaqueToken('AppDocument'); diff --git a/modules/angular2/src/core/compiler/compiler.js b/modules/angular2/src/core/compiler/compiler.js index 4a9cc68d2c..099e074085 100644 --- a/modules/angular2/src/core/compiler/compiler.js +++ b/modules/angular2/src/core/compiler/compiler.js @@ -26,7 +26,7 @@ export class CompilerCache { this._cache = MapWrapper.create(); } - set(component:Type, protoView:AppProtoView) { + set(component:Type, protoView:AppProtoView):void { MapWrapper.set(this._cache, component, protoView); } @@ -35,7 +35,7 @@ export class CompilerCache { return normalizeBlank(result); } - clear() { + clear():void { MapWrapper.clear(this._cache); } } @@ -73,7 +73,7 @@ export class Compiler { this._protoViewFactory = protoViewFactory; } - _bindDirective(directiveTypeOrBinding) { + _bindDirective(directiveTypeOrBinding):DirectiveBinding { if (directiveTypeOrBinding instanceof DirectiveBinding) { return directiveTypeOrBinding; } @@ -190,7 +190,7 @@ export class Compiler { } } - _buildRenderTemplate(component, view, directives) { + _buildRenderTemplate(component, view, directives): renderApi.ViewDefinition { var componentUrl = this._urlResolver.resolve( this._appUrl, this._componentUrlMapper.getUrl(component) ); @@ -211,7 +211,7 @@ export class Compiler { }); } - static buildRenderDirective(directiveBinding) { + static buildRenderDirective(directiveBinding):renderApi.DirectiveMetadata { var ann = directiveBinding.annotation; var renderType; var compileChildren = true; @@ -254,7 +254,7 @@ export class Compiler { return directives; } - _flattenList(tree:List, out:List) { + _flattenList(tree:List, out:List):void { for (var i = 0; i < tree.length; i++) { var item = tree[i]; if (ListWrapper.isList(item)) { diff --git a/modules/angular2/src/core/compiler/dynamic_component_loader.js b/modules/angular2/src/core/compiler/dynamic_component_loader.js index c838bee0c2..fc65823a41 100644 --- a/modules/angular2/src/core/compiler/dynamic_component_loader.js +++ b/modules/angular2/src/core/compiler/dynamic_component_loader.js @@ -123,7 +123,7 @@ export class DynamicComponentLoader { } /** Asserts that the type being dynamically instantiated is a Component. */ - _assertTypeIsComponent(type:Type) { + _assertTypeIsComponent(type:Type):void { var annotation = this._directiveMetadataReader.read(type).annotation; if (!(annotation instanceof Component)) { throw new BaseException(`Could not load '${stringify(type)}' because it is not a component.`); diff --git a/modules/angular2/src/core/compiler/element_injector.js b/modules/angular2/src/core/compiler/element_injector.js index 99b0de7db0..d996880c76 100644 --- a/modules/angular2/src/core/compiler/element_injector.js +++ b/modules/angular2/src/core/compiler/element_injector.js @@ -59,7 +59,7 @@ class StaticKeys { this.elementRefId = Key.get(ElementRef).id; } - static instance() { + static instance():StaticKeys { if (isBlank(_staticKeys)) _staticKeys = new StaticKeys(); return _staticKeys; } @@ -77,17 +77,17 @@ export class TreeNode { if (isPresent(parent)) parent.addChild(this); } - _assertConsistency() { + _assertConsistency():void { this._assertHeadBeforeTail(); this._assertTailReachable(); this._assertPresentInParentList(); } - _assertHeadBeforeTail() { + _assertHeadBeforeTail():void { if (isBlank(this._tail) && isPresent(this._head)) throw new BaseException('null tail but non-null head'); } - _assertTailReachable() { + _assertTailReachable():void { if (isBlank(this._tail)) return; if (isPresent(this._tail._next)) throw new BaseException('node after tail'); var p = this._head; @@ -95,7 +95,7 @@ export class TreeNode { if (isBlank(p) && isPresent(this._tail)) throw new BaseException('tail not reachable.') } - _assertPresentInParentList() { + _assertPresentInParentList():void { var p = this._parent; if (isBlank(p)) { return; @@ -108,7 +108,7 @@ export class TreeNode { /** * Adds a child to the parent node. The child MUST NOT be a part of a tree. */ - addChild(child:TreeNode) { + addChild(child:TreeNode):void { if (isPresent(this._tail)) { this._tail._next = child; this._tail = child; @@ -124,7 +124,7 @@ export class TreeNode { * Adds a child to the parent node after a given sibling. * The child MUST NOT be a part of a tree and the sibling must be present. */ - addChildAfter(child:TreeNode, prevSibling:TreeNode) { + addChildAfter(child:TreeNode, prevSibling:TreeNode):void { this._assertConsistency(); if (isBlank(prevSibling)) { var prevHead = this._head; @@ -146,7 +146,7 @@ export class TreeNode { /** * Detaches a node from the parent's tree. */ - remove() { + remove():void { this._assertConsistency(); if (isBlank(this.parent)) return; var nextSibling = this._next; @@ -209,7 +209,7 @@ export class DirectiveDependency extends Dependency { this._verify(); } - _verify() { + _verify():void { var count = 0; if (isPresent(this.propSetterName)) count++; if (isPresent(this.queryDirective)) count++; diff --git a/modules/angular2/src/core/compiler/ng_element.js b/modules/angular2/src/core/compiler/ng_element.js index 354e0b5f9e..1a6511c9f4 100644 --- a/modules/angular2/src/core/compiler/ng_element.js +++ b/modules/angular2/src/core/compiler/ng_element.js @@ -28,7 +28,7 @@ export class NgElement { return domViewRef.delegate.boundElements[this._boundElementIndex]; } - getAttribute(name:string) { + getAttribute(name:string):string { return normalizeBlank(DOM.getAttribute(this.domElement, name)); } } diff --git a/modules/angular2/src/core/compiler/view.js b/modules/angular2/src/core/compiler/view.js index 93995daa2e..e51d40ea8a 100644 --- a/modules/angular2/src/core/compiler/view.js +++ b/modules/angular2/src/core/compiler/view.js @@ -75,7 +75,7 @@ export class AppView { this.componentChildViews = componentChildViews; } - getOrCreateViewContainer(boundElementIndex:number) { + getOrCreateViewContainer(boundElementIndex:number):ViewContainer { var viewContainer = this.viewContainers[boundElementIndex]; if (isBlank(viewContainer)) { viewContainer = new ViewContainer(this, this.proto.elementBinders[boundElementIndex].nestedProtoView, this.elementInjectors[boundElementIndex]); @@ -84,7 +84,7 @@ export class AppView { return viewContainer; } - setLocal(contextName: string, value) { + setLocal(contextName: string, value):void { if (!this.hydrated()) throw new BaseException('Cannot set locals on dehydrated view.'); if (!MapWrapper.contains(this.proto.variableBindings, contextName)) { return; @@ -93,7 +93,7 @@ export class AppView { this.locals.set(templateName, value); } - hydrated() { + hydrated():boolean { return isPresent(this.context); } @@ -106,14 +106,14 @@ export class AppView { * @param {*} eventObj * @param {int} binderIndex */ - triggerEventHandlers(eventName: string, eventObj, binderIndex: int) { + triggerEventHandlers(eventName: string, eventObj, binderIndex: int): void { var locals = MapWrapper.create(); MapWrapper.set(locals, '$event', eventObj); this.dispatchEvent(binderIndex, eventName, locals); } // dispatch to element injector or text nodes based on context - notifyOnBinding(b:BindingRecord, currentValue:any) { + notifyOnBinding(b:BindingRecord, currentValue:any): void { if (b.isElement()) { this.renderer.setElementProperty( this.render, b.elementIndex, b.propertyName, currentValue @@ -199,7 +199,7 @@ export class AppProtoView { //TODO: Tobias or Victor. Moving it into the constructor. // this work should be done the constructor of AppProtoView once we separate // AppProtoView and ProtoViewBuilder - getVariableBindings() { + getVariableBindings(): List { if (isPresent(this._variableBindings)) { return this._variableBindings; } @@ -217,7 +217,7 @@ export class AppProtoView { //TODO: Tobias or Victor. Moving it into the constructor. // this work should be done the constructor of ProtoView once we separate // AppProtoView and ProtoViewBuilder - getdirectiveRecords() { + getdirectiveRecords(): List { if (isPresent(this._directiveRecords)) { return this._directiveRecords; } @@ -236,7 +236,7 @@ export class AppProtoView { return this._directiveRecords; } - bindVariable(contextName:string, templateName:string) { + bindVariable(contextName:string, templateName:string): void { MapWrapper.set(this.variableBindings, contextName, templateName); MapWrapper.set(this.protoLocals, templateName, null); } @@ -252,7 +252,7 @@ export class AppProtoView { /** * Adds a text node binding for the last created ElementBinder via bindElement */ - bindTextNode(expression:AST) { + bindTextNode(expression:AST):void { var textNodeIndex = this.textNodesWithBindingCount++; var b = BindingRecord.createForTextNode(expression, textNodeIndex); ListWrapper.push(this.bindings, b); @@ -261,7 +261,7 @@ export class AppProtoView { /** * Adds an element property binding for the last created ElementBinder via bindElement */ - bindElementProperty(expression:AST, setterName:string) { + bindElementProperty(expression:AST, setterName:string):void { var elementIndex = this.elementBinders.length-1; var b = BindingRecord.createForElement(expression, elementIndex, setterName); ListWrapper.push(this.bindings, b); @@ -280,7 +280,7 @@ export class AppProtoView { * @param {int} directiveIndex The directive index in the binder or -1 when the event is not bound * to a directive */ - bindEvent(eventBindings: List, directiveIndex: int = -1) { + bindEvent(eventBindings: List, directiveIndex: int = -1): void { var elBinder = this.elementBinders[this.elementBinders.length - 1]; var events = elBinder.hostListeners; if (isBlank(events)) { @@ -306,7 +306,7 @@ export class AppProtoView { directiveIndex:number, expression:AST, setterName:string, - setter:SetterFn) { + setter:SetterFn): void { var elementIndex = this.elementBinders.length-1; var directiveRecord = this._getDirectiveRecord(elementIndex, directiveIndex); @@ -314,7 +314,7 @@ export class AppProtoView { ListWrapper.push(this.bindings, b); } - _getDirectiveRecord(elementInjectorIndex:number, directiveIndex:number) { + _getDirectiveRecord(elementInjectorIndex:number, directiveIndex:number): DirectiveRecord { var id = elementInjectorIndex * 100 + directiveIndex; var protoElementInjector = this.elementBinders[elementInjectorIndex].protoElementInjector; diff --git a/modules/angular2/src/core/compiler/view_container.js b/modules/angular2/src/core/compiler/view_container.js index 27de3230b0..6a3edcbd77 100644 --- a/modules/angular2/src/core/compiler/view_container.js +++ b/modules/angular2/src/core/compiler/view_container.js @@ -27,17 +27,17 @@ export class ViewContainer { this._views = []; } - getRender() { + getRender():ViewContainerRef { return new ViewContainerRef(this.parentView.render, this.elementInjector.getBoundElementIndex()); } - internalClearWithoutRender() { + internalClearWithoutRender():void { for (var i = this._views.length - 1; i >= 0; i--) { this._detachInjectors(i); } } - clear() { + clear():void { for (var i = this._views.length - 1; i >= 0; i--) { this.remove(i); } @@ -47,22 +47,22 @@ export class ViewContainer { return this._views[index]; } - get length() { + get length() /* :int */ { return this._views.length; } - _siblingInjectorToLinkAfter(index: number) { + _siblingInjectorToLinkAfter(index: number):eiModule.ElementInjector { if (index == 0) return null; return ListWrapper.last(this._views[index - 1].rootElementInjectors) } - hydrated() { + hydrated():boolean { return this.parentView.hydrated(); } // TODO(rado): profile and decide whether bounds checks should be added // to the methods below. - create(atIndex=-1, protoView:viewModule.AppProtoView = null, injector:Injector = null): viewModule.AppView { + create(atIndex:number=-1, protoView:viewModule.AppProtoView = null, injector:Injector = null): viewModule.AppView { if (atIndex == -1) atIndex = this._views.length; if (!this.hydrated()) throw new BaseException( 'Cannot create views on a dehydrated ViewContainer'); @@ -77,7 +77,7 @@ export class ViewContainer { return newView; } - insert(view, atIndex=-1): viewModule.AppView { + insert(view:viewModule.AppView, atIndex:number=-1): viewModule.AppView { if (atIndex == -1) atIndex = this._views.length; this._insertInjectors(view, atIndex); this.parentView.changeDetector.addChild(view.changeDetector); @@ -85,7 +85,7 @@ export class ViewContainer { return view; } - _insertInjectors(view, atIndex): viewModule.AppView { + _insertInjectors(view:viewModule.AppView, atIndex:number): viewModule.AppView { ListWrapper.insert(this._views, atIndex, view); this._linkElementInjectors(this._siblingInjectorToLinkAfter(atIndex), view); @@ -96,7 +96,7 @@ export class ViewContainer { return ListWrapper.indexOf(this._views, view); } - remove(atIndex=-1) { + remove(atIndex:number=-1):void { if (atIndex == -1) atIndex = this._views.length - 1; var view = this._views[atIndex]; // opposite order as in create @@ -110,7 +110,7 @@ export class ViewContainer { * The method can be used together with insert to implement a view move, i.e. * moving the dom nodes while the directives in the view stay intact. */ - detach(atIndex=-1): viewModule.AppView { + detach(atIndex:number=-1): viewModule.AppView { if (atIndex == -1) atIndex = this._views.length - 1; var detachedView = this._detachInjectors(atIndex); detachedView.changeDetector.remove(); @@ -118,20 +118,20 @@ export class ViewContainer { return detachedView; } - _detachInjectors(atIndex): viewModule.AppView { + _detachInjectors(atIndex:number): viewModule.AppView { var detachedView = this.get(atIndex); ListWrapper.removeAt(this._views, atIndex); this._unlinkElementInjectors(detachedView); return detachedView; } - _linkElementInjectors(sibling, view) { + _linkElementInjectors(sibling, view:viewModule.AppView):void { for (var i = view.rootElementInjectors.length - 1; i >= 0; i--) { view.rootElementInjectors[i].linkAfter(this.elementInjector, sibling); } } - _unlinkElementInjectors(view) { + _unlinkElementInjectors(view:viewModule.AppView):void { for (var i = 0; i < view.rootElementInjectors.length; ++i) { view.rootElementInjectors[i].unlink(); } diff --git a/modules/angular2/src/di/exceptions.js b/modules/angular2/src/di/exceptions.js index ed0c59838c..3d99ea2e89 100644 --- a/modules/angular2/src/di/exceptions.js +++ b/modules/angular2/src/di/exceptions.js @@ -1,7 +1,7 @@ import {ListWrapper, List} from 'angular2/src/facade/collection'; import {stringify} from 'angular2/src/facade/lang'; -function findFirstClosedCycle(keys:List) { +function findFirstClosedCycle(keys:List):List { var res = []; for(var i = 0; i < keys.length; ++i) { if (ListWrapper.contains(res, keys[i])) { @@ -14,7 +14,7 @@ function findFirstClosedCycle(keys:List) { return res; } -function constructResolvingPath(keys:List) { +function constructResolvingPath(keys:List):string { if (keys.length > 1) { var reversed = findFirstClosedCycle(ListWrapper.reversed(keys)); var tokenStrs = ListWrapper.map(reversed, (k) => stringify(k.token)); @@ -43,12 +43,12 @@ export class AbstractBindingError extends Error { } // TODO(tbosch): Can't do key:Key as this results in a circular dependency! - addKey(key) { + addKey(key):void { ListWrapper.push(this.keys, key); this.message = this.constructResolvingMessage(this.keys); } - toString() { + toString():string { return this.message; } } @@ -166,7 +166,7 @@ export class InvalidBindingError extends Error { this.message = `Invalid binding ${binding}`; } - toString() { + toString():string { return this.message; } } @@ -187,7 +187,7 @@ export class NoAnnotationError extends Error { ` Make sure they all have valid type or annotations.`; } - toString() { + toString():string { return this.message; } } diff --git a/modules/angular2/src/di/injector.js b/modules/angular2/src/di/injector.js index bd2dfd57ee..9570b7a842 100644 --- a/modules/angular2/src/di/injector.js +++ b/modules/angular2/src/di/injector.js @@ -97,7 +97,7 @@ export class Injector { * bindings. * @param `defaultBindings` Setting to true will auto-create bindings. */ - static resolveAndCreate(bindings:List/**/, {defaultBindings=false}={}) { + static resolveAndCreate(bindings:List/**/, {defaultBindings=false}={}): Injector { return new Injector(Injector.resolve(bindings), null, defaultBindings); } @@ -108,7 +108,7 @@ export class Injector { * @param `bindings` A sparse list of {@link ResolvedBinding}s. See `resolve` for the {@link Injector}. * @param `defaultBindings` Setting to true will auto-create bindings. */ - static fromResolvedBindings(bindings:List, {defaultBindings=false}={}) { + static fromResolvedBindings(bindings:List, {defaultBindings=false}={}): Injector { return new Injector(bindings, null, defaultBindings); } @@ -133,7 +133,6 @@ export class Injector { * @returns an instance represented by the token. Throws if not found. */ get(token) { - return this._getByKey(Key.get(token), false, false, false); } @@ -227,7 +226,7 @@ export class Injector { return ListWrapper.get(this._instances, key.id); } - _setInstance(key:Key, obj) { + _setInstance(key:Key, obj):void { ListWrapper.set(this._instances, key.id, obj); } @@ -243,11 +242,11 @@ export class Injector { } } - _markAsConstructing(key:Key) { + _markAsConstructing(key:Key):void { this._setInstance(key, _constructing); } - _clear(key:Key) { + _clear(key:Key):void { this._setInstance(key, null); } } @@ -325,7 +324,7 @@ class _AsyncInjectorStrategy { } } - instantiate(key:Key) { + instantiate(key:Key) /* Promise?? */ { var binding = this.injector._getBinding(key); if (isBlank(binding)) return _notFound; @@ -395,7 +394,7 @@ function _createListOfBindings(flattenedBindings):List { return bindings; } -function _flattenBindings(bindings:List, res:Map) { +function _flattenBindings(bindings:List, res:Map):Map { ListWrapper.forEach(bindings, function (b) { if (b instanceof ResolvedBinding) { MapWrapper.set(res, b.key.id, b); diff --git a/modules/angular2/src/di/opaque_token.js b/modules/angular2/src/di/opaque_token.js index e84f127a86..c7f983bb9b 100644 --- a/modules/angular2/src/di/opaque_token.js +++ b/modules/angular2/src/di/opaque_token.js @@ -10,7 +10,7 @@ export class OpaqueToken { this._desc = `Token(${desc})`; } - toString() { + toString():string { return this._desc; } } \ No newline at end of file diff --git a/modules/angular2/src/directives/class.js b/modules/angular2/src/directives/class.js index 7195cad487..7edffd3e23 100644 --- a/modules/angular2/src/directives/class.js +++ b/modules/angular2/src/directives/class.js @@ -15,7 +15,7 @@ export class CSSClass { this._domEl = ngEl.domElement; } - _toggleClass(className, enabled) { + _toggleClass(className, enabled):void { if (enabled) { DOM.addClass(this._domEl, className); } else { diff --git a/modules/angular2/src/directives/if.js b/modules/angular2/src/directives/if.js index c803f54280..6128b2dccd 100644 --- a/modules/angular2/src/directives/if.js +++ b/modules/angular2/src/directives/if.js @@ -40,7 +40,7 @@ export class If { this.prevCondition = null; } - set condition(newCondition) { + set condition(newCondition /* boolean */) { if (newCondition && (isBlank(this.prevCondition) || !this.prevCondition)) { this.prevCondition = true; this.viewContainer.create(); diff --git a/modules/angular2/src/directives/switch.js b/modules/angular2/src/directives/switch.js index 22a1d80417..642956aa84 100644 --- a/modules/angular2/src/directives/switch.js +++ b/modules/angular2/src/directives/switch.js @@ -65,7 +65,7 @@ export class Switch { this._switchValue = value; } - _onWhenValueChanged(oldWhen, newWhen, viewContainer: ViewContainer) { + _onWhenValueChanged(oldWhen, newWhen, viewContainer: ViewContainer):void { this._deregisterViewContainer(oldWhen, viewContainer); this._registerViewContainer(newWhen, viewContainer); @@ -88,7 +88,7 @@ export class Switch { } } - _emptyAllActiveViewContainers() { + _emptyAllActiveViewContainers():void { var activeContainers = this._activeViewContainers; for (var i = 0; i < activeContainers.length; i++) { activeContainers[i].remove(); @@ -96,7 +96,7 @@ export class Switch { this._activeViewContainers = ListWrapper.create(); } - _activateViewContainers(containers: List) { + _activateViewContainers(containers: List):void { // TODO(vicb): assert(this._activeViewContainers.length === 0); if (isPresent(containers)) { for (var i = 0; i < containers.length; i++) { @@ -106,7 +106,7 @@ export class Switch { } } - _registerViewContainer(value, container: ViewContainer) { + _registerViewContainer(value, container: ViewContainer): void { var containers = MapWrapper.get(this._valueViewContainers, value); if (isBlank(containers)) { containers = ListWrapper.create(); @@ -115,7 +115,7 @@ export class Switch { ListWrapper.push(containers, container); } - _deregisterViewContainer(value, container: ViewContainer) { + _deregisterViewContainer(value, container: ViewContainer):void { // `_whenDefault` is used a marker for non-registered whens if (value == _whenDefault) return; var containers = MapWrapper.get(this._valueViewContainers, value); diff --git a/modules/angular2/src/dom/dom_adapter.js b/modules/angular2/src/dom/dom_adapter.js index 8465d15e88..d2adf3cb50 100644 --- a/modules/angular2/src/dom/dom_adapter.js +++ b/modules/angular2/src/dom/dom_adapter.js @@ -195,7 +195,7 @@ export class DomAdapter { attributeMap(element) { throw _abstract(); } - getAttribute(element, attribute:string) { + getAttribute(element, attribute:string):string { throw _abstract(); } setAttribute(element, name:string, value:string) {