chore: add more types to a number of top-level properties and methods

This commit is contained in:
Kevin Moore 2015-05-05 12:59:54 -07:00
parent c8ebd11d63
commit 75db2c5241
9 changed files with 25 additions and 29 deletions

View File

@ -20,7 +20,7 @@ import {Location} from './src/router/location';
import {appComponentAnnotatedTypeToken} from './src/core/application_tokens'; import {appComponentAnnotatedTypeToken} from './src/core/application_tokens';
import {bind} from './di'; import {bind} from './di';
export var routerInjectables = [ export var routerInjectables:List = [
RouteRegistry, RouteRegistry,
Pipeline, Pipeline,
Location, Location,

View File

@ -93,4 +93,4 @@ export class JitChangeDetection extends ChangeDetection {
} }
} }
export var defaultPipeRegistry = new PipeRegistry(defaultPipes); export var defaultPipeRegistry:PipeRegistry = new PipeRegistry(defaultPipes);

View File

@ -134,7 +134,7 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
} }
MouseEvent createMouseEvent(String eventType) => MouseEvent createMouseEvent(String eventType) =>
new MouseEvent(eventType, canBubble: true); 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 getInnerHTML(Element el) => el.innerHtml;
String getOuterHTML(Element el) => el.outerHtml; String getOuterHTML(Element el) => el.outerHtml;
void setInnerHTML(Element el, String value) { void setInnerHTML(Element el, String value) {

View File

@ -52,7 +52,7 @@ export class DomAdapter {
createMouseEvent(eventType) { createMouseEvent(eventType) {
throw _abstract(); throw _abstract();
} }
createEvent(eventType) { createEvent(eventType:string) {
throw _abstract(); throw _abstract();
} }
getInnerHTML(el) { getInnerHTML(el) {

View File

@ -146,7 +146,7 @@ class Html5LibDomAdapter implements DomAdapter {
setChecked(el, bool value) { setChecked(el, bool value) {
throw 'not implemented'; throw 'not implemented';
} }
createTemplate(html) => createElement('template')..innerHtml = html; createTemplate(String html) => createElement('template')..innerHtml = html;
createElement(tagName, [doc]) { createElement(tagName, [doc]) {
return new Element.tag(tagName); return new Element.tag(tagName);
} }

View File

@ -272,6 +272,6 @@ export class ControlGroupDirective {
* @exportedAs angular2/forms * @exportedAs angular2/forms
*/ */
// todo(misko): rename to lover case as it is not a Type but a var. // 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 ControlGroupDirective, ControlDirective, CheckboxControlValueAccessor, DefaultValueAccessor
]; ];

View File

@ -118,7 +118,7 @@ function _getAppBindings() {
]; ];
} }
export function createTestInjector(bindings: List) { export function createTestInjector(bindings: List):Injector {
var rootInjector = Injector.resolveAndCreate(_getRootBindings()); var rootInjector = Injector.resolveAndCreate(_getRootBindings());
return rootInjector.resolveAndCreateChild(ListWrapper.concat(_getAppBindings(), bindings)); return rootInjector.resolveAndCreateChild(ListWrapper.concat(_getAppBindings(), bindings));
} }
@ -153,7 +153,7 @@ export function createTestInjector(bindings: List) {
* @return {FunctionWithParamTokens} * @return {FunctionWithParamTokens}
* @exportedAs angular2/test * @exportedAs angular2/test
*/ */
export function inject(tokens: List, fn: Function) { export function inject(tokens: List, fn: Function):FunctionWithParamTokens {
return new FunctionWithParamTokens(tokens, fn); return new FunctionWithParamTokens(tokens, fn);
} }
@ -166,7 +166,7 @@ export class FunctionWithParamTokens {
this._fn = fn; this._fn = fn;
} }
execute(injector: Injector) { execute(injector: Injector):void {
var params = ListWrapper.map(this._tokens, (t) => injector.get(t)); var params = ListWrapper.map(this._tokens, (t) => injector.get(t));
FunctionWrapper.apply(this._fn, params); FunctionWrapper.apply(this._fn, params);
} }

View File

@ -26,20 +26,16 @@ bool _isCurrentTestAsync;
bool _inIt = false; bool _inIt = false;
class AsyncTestCompleter { class AsyncTestCompleter {
Completer _completer; final _completer = new Completer();
AsyncTestCompleter() { void done() {
_completer = new Completer();
}
done() {
_completer.complete(); _completer.complete();
} }
get future => _completer.future; Future get future => _completer.future;
} }
testSetup() { void testSetup() {
reflector.reflectionCapabilities = new ReflectionCapabilities(); reflector.reflectionCapabilities = new ReflectionCapabilities();
// beforeEach configuration: // beforeEach configuration:
// - Priority 3: clear the bindings before each test, // - Priority 3: clear the bindings before each test,
@ -125,7 +121,7 @@ class NotExpect extends gns.NotExpect {
Function get _expect => gns.guinness.matchers.expect; Function get _expect => gns.guinness.matchers.expect;
} }
beforeEach(fn) { void beforeEach(fn) {
if (fn is! FunctionWithParamTokens) fn = new FunctionWithParamTokens([], fn); if (fn is! FunctionWithParamTokens) fn = new FunctionWithParamTokens([], fn);
gns.beforeEach(() { gns.beforeEach(() {
fn.execute(_injector); fn.execute(_injector);
@ -144,7 +140,7 @@ beforeEach(fn) {
* bind(SomeToken).toValue(myValue), * bind(SomeToken).toValue(myValue),
* ]); * ]);
*/ */
beforeEachBindings(fn) { void beforeEachBindings(Function fn) {
gns.beforeEach( gns.beforeEach(
() { () {
var bindings = fn(); 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); if (fn is! FunctionWithParamTokens) fn = new FunctionWithParamTokens([], fn);
gnsFn(name, () { gnsFn(name, () {
_inIt = true; _inIt = true;
@ -165,20 +161,20 @@ _it(gnsFn, name, fn) {
} }
it(name, fn) { void it(name, fn) {
_it(gns.it, name, fn); _it(gns.it, name, fn);
} }
iit(name, fn) { void iit(name, fn) {
_it(gns.iit, name, fn); _it(gns.iit, name, fn);
} }
xit(name, fn) { void xit(name, fn) {
_it(gns.xit, name, fn); _it(gns.xit, name, fn);
} }
class SpyFunction extends gns.SpyFunction { class SpyFunction extends gns.SpyFunction {
SpyFunction(name): super(name); SpyFunction(String name): super(name);
// TODO: vsavkin move to guinness // TODO: vsavkin move to guinness
andReturn(value) { andReturn(value) {

View File

@ -9,7 +9,7 @@ export class Log {
this._result = []; this._result = [];
} }
add(value) { add(value):void {
ListWrapper.push(this._result, value); ListWrapper.push(this._result, value);
} }
@ -19,16 +19,16 @@ export class Log {
} }
} }
result() { result():string {
return ListWrapper.join(this._result, "; "); return ListWrapper.join(this._result, "; ");
} }
} }
export function viewRootNodes(view) { export function viewRootNodes(view):List {
return view.render.delegate.rootNodes; return view.render.delegate.rootNodes;
} }
export function queryView(view, selector) { export function queryView(view, selector:string) {
var rootNodes = viewRootNodes(view); var rootNodes = viewRootNodes(view);
for (var i = 0; i < rootNodes.length; ++i) { for (var i = 0; i < rootNodes.length; ++i) {
var res = DOM.querySelector(rootNodes[i], selector); var res = DOM.querySelector(rootNodes[i], selector);
@ -43,6 +43,6 @@ export function dispatchEvent(element, eventType) {
DOM.dispatchEvent(element, DOM.createEvent(eventType)); DOM.dispatchEvent(element, DOM.createEvent(eventType));
} }
export function el(html) { export function el(html:string) {
return DOM.firstChild(DOM.content(DOM.createTemplate(html))); return DOM.firstChild(DOM.content(DOM.createTemplate(html)));
} }