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

@ -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);
}

View File

@ -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) {

View File

@ -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)));
}