From 75db2c52411c801afa138800fe20cec3b731184e Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 5 May 2015 12:59:54 -0700 Subject: [PATCH] chore: add more types to a number of top-level properties and methods --- modules/angular2/router.js | 2 +- .../src/change_detection/change_detection.js | 2 +- modules/angular2/src/dom/browser_adapter.dart | 2 +- modules/angular2/src/dom/dom_adapter.js | 2 +- modules/angular2/src/dom/html_adapter.dart | 2 +- modules/angular2/src/forms/directives.js | 2 +- .../angular2/src/test_lib/test_injector.js | 6 ++--- modules/angular2/src/test_lib/test_lib.dart | 26 ++++++++----------- modules/angular2/src/test_lib/utils.js | 10 +++---- 9 files changed, 25 insertions(+), 29 deletions(-) diff --git a/modules/angular2/router.js b/modules/angular2/router.js index 1dfaafcbf7..a311805b7c 100644 --- a/modules/angular2/router.js +++ b/modules/angular2/router.js @@ -20,7 +20,7 @@ import {Location} from './src/router/location'; import {appComponentAnnotatedTypeToken} from './src/core/application_tokens'; import {bind} from './di'; -export var routerInjectables = [ +export var routerInjectables:List = [ RouteRegistry, Pipeline, Location, diff --git a/modules/angular2/src/change_detection/change_detection.js b/modules/angular2/src/change_detection/change_detection.js index e21293aac3..dc1ec515f3 100644 --- a/modules/angular2/src/change_detection/change_detection.js +++ b/modules/angular2/src/change_detection/change_detection.js @@ -93,4 +93,4 @@ export class JitChangeDetection extends ChangeDetection { } } -export var defaultPipeRegistry = new PipeRegistry(defaultPipes); +export var defaultPipeRegistry:PipeRegistry = new PipeRegistry(defaultPipes); diff --git a/modules/angular2/src/dom/browser_adapter.dart b/modules/angular2/src/dom/browser_adapter.dart index b9763886a6..1588c1772d 100644 --- a/modules/angular2/src/dom/browser_adapter.dart +++ b/modules/angular2/src/dom/browser_adapter.dart @@ -134,7 +134,7 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter { } MouseEvent createMouseEvent(String eventType) => new MouseEvent(eventType, canBubble: true); - Event createEvent(eventType) => new Event(eventType, canBubble: true); + Event createEvent(String eventType) => new Event(eventType, canBubble: true); String getInnerHTML(Element el) => el.innerHtml; String getOuterHTML(Element el) => el.outerHtml; void setInnerHTML(Element el, String value) { diff --git a/modules/angular2/src/dom/dom_adapter.js b/modules/angular2/src/dom/dom_adapter.js index c25f5c70f5..ae75257f3f 100644 --- a/modules/angular2/src/dom/dom_adapter.js +++ b/modules/angular2/src/dom/dom_adapter.js @@ -52,7 +52,7 @@ export class DomAdapter { createMouseEvent(eventType) { throw _abstract(); } - createEvent(eventType) { + createEvent(eventType:string) { throw _abstract(); } getInnerHTML(el) { diff --git a/modules/angular2/src/dom/html_adapter.dart b/modules/angular2/src/dom/html_adapter.dart index c74537a81d..5b7173a65b 100644 --- a/modules/angular2/src/dom/html_adapter.dart +++ b/modules/angular2/src/dom/html_adapter.dart @@ -146,7 +146,7 @@ class Html5LibDomAdapter implements DomAdapter { setChecked(el, bool value) { throw 'not implemented'; } - createTemplate(html) => createElement('template')..innerHtml = html; + createTemplate(String html) => createElement('template')..innerHtml = html; createElement(tagName, [doc]) { return new Element.tag(tagName); } diff --git a/modules/angular2/src/forms/directives.js b/modules/angular2/src/forms/directives.js index fd58ad527e..7271b1fa19 100644 --- a/modules/angular2/src/forms/directives.js +++ b/modules/angular2/src/forms/directives.js @@ -272,6 +272,6 @@ export class ControlGroupDirective { * @exportedAs angular2/forms */ // todo(misko): rename to lover case as it is not a Type but a var. -export var FormDirectives = [ +export var FormDirectives:List = [ ControlGroupDirective, ControlDirective, CheckboxControlValueAccessor, DefaultValueAccessor ]; diff --git a/modules/angular2/src/test_lib/test_injector.js b/modules/angular2/src/test_lib/test_injector.js index 028a4eaa56..cedd03bfc8 100644 --- a/modules/angular2/src/test_lib/test_injector.js +++ b/modules/angular2/src/test_lib/test_injector.js @@ -118,7 +118,7 @@ function _getAppBindings() { ]; } -export function createTestInjector(bindings: List) { +export function createTestInjector(bindings: List):Injector { var rootInjector = Injector.resolveAndCreate(_getRootBindings()); return rootInjector.resolveAndCreateChild(ListWrapper.concat(_getAppBindings(), bindings)); } @@ -153,7 +153,7 @@ export function createTestInjector(bindings: List) { * @return {FunctionWithParamTokens} * @exportedAs angular2/test */ -export function inject(tokens: List, fn: Function) { +export function inject(tokens: List, fn: Function):FunctionWithParamTokens { return new FunctionWithParamTokens(tokens, fn); } @@ -166,7 +166,7 @@ export class FunctionWithParamTokens { this._fn = fn; } - execute(injector: Injector) { + execute(injector: Injector):void { var params = ListWrapper.map(this._tokens, (t) => injector.get(t)); FunctionWrapper.apply(this._fn, params); } diff --git a/modules/angular2/src/test_lib/test_lib.dart b/modules/angular2/src/test_lib/test_lib.dart index c65fe33696..8785f079b5 100644 --- a/modules/angular2/src/test_lib/test_lib.dart +++ b/modules/angular2/src/test_lib/test_lib.dart @@ -26,20 +26,16 @@ bool _isCurrentTestAsync; bool _inIt = false; class AsyncTestCompleter { - Completer _completer; + final _completer = new Completer(); - AsyncTestCompleter() { - _completer = new Completer(); - } - - done() { + void done() { _completer.complete(); } - get future => _completer.future; + Future get future => _completer.future; } -testSetup() { +void testSetup() { reflector.reflectionCapabilities = new ReflectionCapabilities(); // beforeEach configuration: // - Priority 3: clear the bindings before each test, @@ -125,7 +121,7 @@ class NotExpect extends gns.NotExpect { Function get _expect => gns.guinness.matchers.expect; } -beforeEach(fn) { +void beforeEach(fn) { if (fn is! FunctionWithParamTokens) fn = new FunctionWithParamTokens([], fn); gns.beforeEach(() { fn.execute(_injector); @@ -144,7 +140,7 @@ beforeEach(fn) { * bind(SomeToken).toValue(myValue), * ]); */ -beforeEachBindings(fn) { +void beforeEachBindings(Function fn) { gns.beforeEach( () { var bindings = fn(); @@ -154,7 +150,7 @@ beforeEachBindings(fn) { ); } -_it(gnsFn, name, fn) { +void _it(gnsFn, name, fn) { if (fn is! FunctionWithParamTokens) fn = new FunctionWithParamTokens([], fn); gnsFn(name, () { _inIt = true; @@ -165,20 +161,20 @@ _it(gnsFn, name, fn) { } -it(name, fn) { +void it(name, fn) { _it(gns.it, name, fn); } -iit(name, fn) { +void iit(name, fn) { _it(gns.iit, name, fn); } -xit(name, fn) { +void xit(name, fn) { _it(gns.xit, name, fn); } class SpyFunction extends gns.SpyFunction { - SpyFunction(name): super(name); + SpyFunction(String name): super(name); // TODO: vsavkin move to guinness andReturn(value) { diff --git a/modules/angular2/src/test_lib/utils.js b/modules/angular2/src/test_lib/utils.js index 3e88ffe649..4c859e99e9 100644 --- a/modules/angular2/src/test_lib/utils.js +++ b/modules/angular2/src/test_lib/utils.js @@ -9,7 +9,7 @@ export class Log { this._result = []; } - add(value) { + add(value):void { ListWrapper.push(this._result, value); } @@ -19,16 +19,16 @@ export class Log { } } - result() { + result():string { return ListWrapper.join(this._result, "; "); } } -export function viewRootNodes(view) { +export function viewRootNodes(view):List { return view.render.delegate.rootNodes; } -export function queryView(view, selector) { +export function queryView(view, selector:string) { var rootNodes = viewRootNodes(view); for (var i = 0; i < rootNodes.length; ++i) { var res = DOM.querySelector(rootNodes[i], selector); @@ -43,6 +43,6 @@ export function dispatchEvent(element, eventType) { DOM.dispatchEvent(element, DOM.createEvent(eventType)); } -export function el(html) { +export function el(html:string) { return DOM.firstChild(DOM.content(DOM.createTemplate(html))); }