Skip to content

Commit f7f06c5

Browse files
committed
chore: add more type annotations
1 parent e23004d commit f7f06c5

File tree

17 files changed

+80
-81
lines changed

17 files changed

+80
-81
lines changed

modules/angular2/src/change_detection/parser/ast.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export class AST {
66
throw new BaseException("Not supported");
77
}
88

9-
get isAssignable() {
9+
get isAssignable():boolean {
1010
return false;
1111
}
1212

@@ -113,7 +113,7 @@ export class AccessMember extends AST {
113113
}
114114
}
115115

116-
get isAssignable() {
116+
get isAssignable():boolean {
117117
return true;
118118
}
119119

@@ -148,7 +148,7 @@ export class KeyedAccess extends AST {
148148
return obj[key];
149149
}
150150

151-
get isAssignable() {
151+
get isAssignable():boolean {
152152
return true;
153153
}
154154

@@ -397,7 +397,7 @@ export class ASTWithSource extends AST {
397397
return this.ast.eval(context, locals);
398398
}
399399

400-
get isAssignable() {
400+
get isAssignable():boolean {
401401
return this.ast.isAssignable;
402402
}
403403

modules/angular2/src/change_detection/parser/locals.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class Locals {
3434
throw new BaseException(`Cannot find '${name}'`);
3535
}
3636

37-
set(name:string, value) {
37+
set(name:string, value):void {
3838
// TODO(rado): consider removing this check if we can guarantee this is not
3939
// exposed to the public API.
4040
// TODO: vsavkin maybe it should check only the local map
@@ -45,7 +45,7 @@ export class Locals {
4545
}
4646
}
4747

48-
clearValues() {
48+
clearValues():void {
4949
MapWrapper.clearValues(this.current);
5050
}
5151
}

modules/angular2/src/core/annotations/view.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ export class View {
3838
*
3939
* NOTE: either `templateURL` or `template` should be used, but not both.
4040
*/
41-
templateUrl:any; //string;
41+
templateUrl:string;
4242

4343
/**
4444
* Specifies an inline template for an angular component.
4545
*
4646
* NOTE: either `templateURL` or `template` should be used, but not both.
4747
*/
48-
template:any; //string;
48+
template:string;
4949

5050
/**
5151
* Specifies a list of directives that can be used within a template.
@@ -69,7 +69,7 @@ export class View {
6969
* }
7070
* ```
7171
*/
72-
directives:any; //List<Type>;
72+
directives:List<Type>;
7373

7474
/**
7575
* Specify a custom renderer for this View.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {OpaqueToken} from 'angular2/di';
22

3-
export var appComponentRefToken = new OpaqueToken('ComponentRef');
4-
export var appChangeDetectorToken = new OpaqueToken('AppChangeDetector');
5-
export var appElementToken = new OpaqueToken('AppElement');
6-
export var appComponentAnnotatedTypeToken = new OpaqueToken('AppComponentAnnotatedType');
7-
export var appDocumentToken = new OpaqueToken('AppDocument');
3+
export var appComponentRefToken:OpaqueToken = new OpaqueToken('ComponentRef');
4+
export var appChangeDetectorToken:OpaqueToken = new OpaqueToken('AppChangeDetector');
5+
export var appElementToken:OpaqueToken = new OpaqueToken('AppElement');
6+
export var appComponentAnnotatedTypeToken:OpaqueToken = new OpaqueToken('AppComponentAnnotatedType');
7+
export var appDocumentToken:OpaqueToken = new OpaqueToken('AppDocument');

modules/angular2/src/core/compiler/compiler.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class CompilerCache {
2626
this._cache = MapWrapper.create();
2727
}
2828

29-
set(component:Type, protoView:AppProtoView) {
29+
set(component:Type, protoView:AppProtoView):void {
3030
MapWrapper.set(this._cache, component, protoView);
3131
}
3232

@@ -35,7 +35,7 @@ export class CompilerCache {
3535
return normalizeBlank(result);
3636
}
3737

38-
clear() {
38+
clear():void {
3939
MapWrapper.clear(this._cache);
4040
}
4141
}
@@ -73,7 +73,7 @@ export class Compiler {
7373
this._protoViewFactory = protoViewFactory;
7474
}
7575

76-
_bindDirective(directiveTypeOrBinding) {
76+
_bindDirective(directiveTypeOrBinding):DirectiveBinding {
7777
if (directiveTypeOrBinding instanceof DirectiveBinding) {
7878
return directiveTypeOrBinding;
7979
}
@@ -190,7 +190,7 @@ export class Compiler {
190190
}
191191
}
192192

193-
_buildRenderTemplate(component, view, directives) {
193+
_buildRenderTemplate(component, view, directives): renderApi.ViewDefinition {
194194
var componentUrl = this._urlResolver.resolve(
195195
this._appUrl, this._componentUrlMapper.getUrl(component)
196196
);
@@ -211,7 +211,7 @@ export class Compiler {
211211
});
212212
}
213213

214-
static buildRenderDirective(directiveBinding) {
214+
static buildRenderDirective(directiveBinding):renderApi.DirectiveMetadata {
215215
var ann = directiveBinding.annotation;
216216
var renderType;
217217
var compileChildren = true;
@@ -254,7 +254,7 @@ export class Compiler {
254254
return directives;
255255
}
256256

257-
_flattenList(tree:List<any>, out:List<Type>) {
257+
_flattenList(tree:List<any>, out:List<Type>):void {
258258
for (var i = 0; i < tree.length; i++) {
259259
var item = tree[i];
260260
if (ListWrapper.isList(item)) {

modules/angular2/src/core/compiler/dynamic_component_loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class DynamicComponentLoader {
123123
}
124124

125125
/** Asserts that the type being dynamically instantiated is a Component. */
126-
_assertTypeIsComponent(type:Type) {
126+
_assertTypeIsComponent(type:Type):void {
127127
var annotation = this._directiveMetadataReader.read(type).annotation;
128128
if (!(annotation instanceof Component)) {
129129
throw new BaseException(`Could not load '${stringify(type)}' because it is not a component.`);

modules/angular2/src/core/compiler/element_injector.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class StaticKeys {
5959
this.elementRefId = Key.get(ElementRef).id;
6060
}
6161

62-
static instance() {
62+
static instance():StaticKeys {
6363
if (isBlank(_staticKeys)) _staticKeys = new StaticKeys();
6464
return _staticKeys;
6565
}
@@ -77,25 +77,25 @@ export class TreeNode {
7777
if (isPresent(parent)) parent.addChild(this);
7878
}
7979

80-
_assertConsistency() {
80+
_assertConsistency():void {
8181
this._assertHeadBeforeTail();
8282
this._assertTailReachable();
8383
this._assertPresentInParentList();
8484
}
8585

86-
_assertHeadBeforeTail() {
86+
_assertHeadBeforeTail():void {
8787
if (isBlank(this._tail) && isPresent(this._head)) throw new BaseException('null tail but non-null head');
8888
}
8989

90-
_assertTailReachable() {
90+
_assertTailReachable():void {
9191
if (isBlank(this._tail)) return;
9292
if (isPresent(this._tail._next)) throw new BaseException('node after tail');
9393
var p = this._head;
9494
while (isPresent(p) && p != this._tail) p = p._next;
9595
if (isBlank(p) && isPresent(this._tail)) throw new BaseException('tail not reachable.')
9696
}
9797

98-
_assertPresentInParentList() {
98+
_assertPresentInParentList():void {
9999
var p = this._parent;
100100
if (isBlank(p)) {
101101
return;
@@ -108,7 +108,7 @@ export class TreeNode {
108108
/**
109109
* Adds a child to the parent node. The child MUST NOT be a part of a tree.
110110
*/
111-
addChild(child:TreeNode) {
111+
addChild(child:TreeNode):void {
112112
if (isPresent(this._tail)) {
113113
this._tail._next = child;
114114
this._tail = child;
@@ -124,7 +124,7 @@ export class TreeNode {
124124
* Adds a child to the parent node after a given sibling.
125125
* The child MUST NOT be a part of a tree and the sibling must be present.
126126
*/
127-
addChildAfter(child:TreeNode, prevSibling:TreeNode) {
127+
addChildAfter(child:TreeNode, prevSibling:TreeNode):void {
128128
this._assertConsistency();
129129
if (isBlank(prevSibling)) {
130130
var prevHead = this._head;
@@ -146,7 +146,7 @@ export class TreeNode {
146146
/**
147147
* Detaches a node from the parent's tree.
148148
*/
149-
remove() {
149+
remove():void {
150150
this._assertConsistency();
151151
if (isBlank(this.parent)) return;
152152
var nextSibling = this._next;
@@ -209,7 +209,7 @@ export class DirectiveDependency extends Dependency {
209209
this._verify();
210210
}
211211

212-
_verify() {
212+
_verify():void {
213213
var count = 0;
214214
if (isPresent(this.propSetterName)) count++;
215215
if (isPresent(this.queryDirective)) count++;

modules/angular2/src/core/compiler/ng_element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class NgElement {
2828
return domViewRef.delegate.boundElements[this._boundElementIndex];
2929
}
3030

31-
getAttribute(name:string) {
31+
getAttribute(name:string):string {
3232
return normalizeBlank(DOM.getAttribute(this.domElement, name));
3333
}
3434
}

modules/angular2/src/core/compiler/view.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class AppView {
7575
this.componentChildViews = componentChildViews;
7676
}
7777

78-
getOrCreateViewContainer(boundElementIndex:number) {
78+
getOrCreateViewContainer(boundElementIndex:number):ViewContainer {
7979
var viewContainer = this.viewContainers[boundElementIndex];
8080
if (isBlank(viewContainer)) {
8181
viewContainer = new ViewContainer(this, this.proto.elementBinders[boundElementIndex].nestedProtoView, this.elementInjectors[boundElementIndex]);
@@ -84,7 +84,7 @@ export class AppView {
8484
return viewContainer;
8585
}
8686

87-
setLocal(contextName: string, value) {
87+
setLocal(contextName: string, value):void {
8888
if (!this.hydrated()) throw new BaseException('Cannot set locals on dehydrated view.');
8989
if (!MapWrapper.contains(this.proto.variableBindings, contextName)) {
9090
return;
@@ -93,7 +93,7 @@ export class AppView {
9393
this.locals.set(templateName, value);
9494
}
9595

96-
hydrated() {
96+
hydrated():boolean {
9797
return isPresent(this.context);
9898
}
9999

@@ -106,14 +106,14 @@ export class AppView {
106106
* @param {*} eventObj
107107
* @param {int} binderIndex
108108
*/
109-
triggerEventHandlers(eventName: string, eventObj, binderIndex: int) {
109+
triggerEventHandlers(eventName: string, eventObj, binderIndex: int): void {
110110
var locals = MapWrapper.create();
111111
MapWrapper.set(locals, '$event', eventObj);
112112
this.dispatchEvent(binderIndex, eventName, locals);
113113
}
114114

115115
// dispatch to element injector or text nodes based on context
116-
notifyOnBinding(b:BindingRecord, currentValue:any) {
116+
notifyOnBinding(b:BindingRecord, currentValue:any): void {
117117
if (b.isElement()) {
118118
this.renderer.setElementProperty(
119119
this.render, b.elementIndex, b.propertyName, currentValue
@@ -199,7 +199,7 @@ export class AppProtoView {
199199
//TODO: Tobias or Victor. Moving it into the constructor.
200200
// this work should be done the constructor of AppProtoView once we separate
201201
// AppProtoView and ProtoViewBuilder
202-
getVariableBindings() {
202+
getVariableBindings(): List {
203203
if (isPresent(this._variableBindings)) {
204204
return this._variableBindings;
205205
}
@@ -217,7 +217,7 @@ export class AppProtoView {
217217
//TODO: Tobias or Victor. Moving it into the constructor.
218218
// this work should be done the constructor of ProtoView once we separate
219219
// AppProtoView and ProtoViewBuilder
220-
getdirectiveRecords() {
220+
getdirectiveRecords(): List {
221221
if (isPresent(this._directiveRecords)) {
222222
return this._directiveRecords;
223223
}
@@ -236,7 +236,7 @@ export class AppProtoView {
236236
return this._directiveRecords;
237237
}
238238

239-
bindVariable(contextName:string, templateName:string) {
239+
bindVariable(contextName:string, templateName:string): void {
240240
MapWrapper.set(this.variableBindings, contextName, templateName);
241241
MapWrapper.set(this.protoLocals, templateName, null);
242242
}
@@ -252,7 +252,7 @@ export class AppProtoView {
252252
/**
253253
* Adds a text node binding for the last created ElementBinder via bindElement
254254
*/
255-
bindTextNode(expression:AST) {
255+
bindTextNode(expression:AST):void {
256256
var textNodeIndex = this.textNodesWithBindingCount++;
257257
var b = BindingRecord.createForTextNode(expression, textNodeIndex);
258258
ListWrapper.push(this.bindings, b);
@@ -261,7 +261,7 @@ export class AppProtoView {
261261
/**
262262
* Adds an element property binding for the last created ElementBinder via bindElement
263263
*/
264-
bindElementProperty(expression:AST, setterName:string) {
264+
bindElementProperty(expression:AST, setterName:string):void {
265265
var elementIndex = this.elementBinders.length-1;
266266
var b = BindingRecord.createForElement(expression, elementIndex, setterName);
267267
ListWrapper.push(this.bindings, b);
@@ -280,7 +280,7 @@ export class AppProtoView {
280280
* @param {int} directiveIndex The directive index in the binder or -1 when the event is not bound
281281
* to a directive
282282
*/
283-
bindEvent(eventBindings: List<renderApi.EventBinding>, directiveIndex: int = -1) {
283+
bindEvent(eventBindings: List<renderApi.EventBinding>, directiveIndex: int = -1): void {
284284
var elBinder = this.elementBinders[this.elementBinders.length - 1];
285285
var events = elBinder.hostListeners;
286286
if (isBlank(events)) {
@@ -306,15 +306,15 @@ export class AppProtoView {
306306
directiveIndex:number,
307307
expression:AST,
308308
setterName:string,
309-
setter:SetterFn) {
309+
setter:SetterFn): void {
310310

311311
var elementIndex = this.elementBinders.length-1;
312312
var directiveRecord = this._getDirectiveRecord(elementIndex, directiveIndex);
313313
var b = BindingRecord.createForDirective(expression, setterName, setter, directiveRecord);
314314
ListWrapper.push(this.bindings, b);
315315
}
316316

317-
_getDirectiveRecord(elementInjectorIndex:number, directiveIndex:number) {
317+
_getDirectiveRecord(elementInjectorIndex:number, directiveIndex:number): DirectiveRecord {
318318
var id = elementInjectorIndex * 100 + directiveIndex;
319319
var protoElementInjector = this.elementBinders[elementInjectorIndex].protoElementInjector;
320320

0 commit comments

Comments
 (0)