feat(build): require parameter types

Fixes #2833
This commit is contained in:
Alex Eagle
2015-07-07 20:03:00 -07:00
parent 6d760666a9
commit de18da2a0d
81 changed files with 379 additions and 290 deletions

View File

@ -286,7 +286,7 @@ export class EventEmitterAccessor {
subscribe(view: viewModule.AppView, boundElementIndex: number, directive: Object): Object {
var eventEmitter = this.getter(directive);
return ObservableWrapper.subscribe(
return ObservableWrapper.subscribe<Event>(
eventEmitter,
eventObj => view.triggerEventHandlers(this.eventName, eventObj, boundElementIndex));
}
@ -297,7 +297,7 @@ export class HostActionAccessor {
subscribe(view: viewModule.AppView, boundElementIndex: number, directive: Object): Object {
var eventEmitter = this.getter(directive);
return ObservableWrapper.subscribe(
return ObservableWrapper.subscribe<List<any>>(
eventEmitter,
actionArgs => view.invokeElementMethod(boundElementIndex, this.methodName, actionArgs));
}
@ -542,7 +542,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
return isPresent(index) ? this.getDirectiveAtIndex(<number>index) : this.getElementRef();
}
get(token): any { return this._injector.get(token); }
get(token: any): any { return this._injector.get(token); }
hasDirective(type: Type): boolean { return isPresent(this._injector.getOptional(type)); }

View File

@ -135,7 +135,7 @@ export class AppView implements ChangeDispatcher, RenderEventDispatcher {
this.viewContainers = viewContainers;
}
setLocal(contextName: string, value): void {
setLocal(contextName: string, value: any): void {
if (!this.hydrated()) throw new BaseException('Cannot set locals on dehydrated view.');
if (!this.proto.variableBindings.has(contextName)) {
return;
@ -155,7 +155,7 @@ export class AppView implements ChangeDispatcher, RenderEventDispatcher {
* @param {*} eventObj
* @param {int} boundElementIndex
*/
triggerEventHandlers(eventName: string, eventObj, boundElementIndex: int): void {
triggerEventHandlers(eventName: string, eventObj: Event, boundElementIndex: int): void {
var locals = new Map();
locals.set('$event', eventObj);
this.dispatchEvent(boundElementIndex, eventName, locals);

View File

@ -33,9 +33,9 @@ import {DOM} from 'angular2/src/dom/dom_adapter';
*/
@Injectable()
export class ExceptionHandler {
call(error, stackTrace = null, reason = null) {
call(error: Object, stackTrace: string | List<string> = null, reason: string = null) {
var longStackTrace =
isListLikeIterable(stackTrace) ? ListWrapper.join(stackTrace, "\n\n") : stackTrace;
isListLikeIterable(stackTrace) ? ListWrapper.join(<any>stackTrace, "\n\n") : stackTrace;
var reasonStr = isPresent(reason) ? `\n${reason}` : '';
DOM.logError(`${error}${reasonStr}\nSTACKTRACE:\n${longStackTrace}`);
}

View File

@ -8,14 +8,14 @@ class PublicTestability {
whenStable(callback: Function) { this._testability.whenStable(callback); }
findBindings(using, binding: string, exactMatch: boolean): List<any> {
findBindings(using: any, binding: string, exactMatch: boolean): List<any> {
return this._testability.findBindings(using, binding, exactMatch);
}
}
export class GetTestability {
static addToWindow(registry: TestabilityRegistry) {
global.getAngularTestability = function(elem): PublicTestability {
global.getAngularTestability = function(elem: Element): PublicTestability {
var testability = registry.findTestabilityInTree(elem);
if (testability == null) {

View File

@ -47,7 +47,7 @@ export class Testability {
getPendingCount(): number { return this._pendingCount; }
findBindings(using, binding: string, exactMatch: boolean): List<any> {
findBindings(using: any, binding: string, exactMatch: boolean): List<any> {
// TODO(juliemr): implement.
return [];
}
@ -63,11 +63,11 @@ export class TestabilityRegistry {
getTestabilityModule.GetTestability.addToWindow(this);
}
registerApplication(token, testability: Testability) {
registerApplication(token: any, testability: Testability) {
this._applications.set(token, testability);
}
findTestabilityInTree(elem): Testability {
findTestabilityInTree(elem: Node): Testability {
if (elem == null) {
return null;
}

View File

@ -121,7 +121,7 @@ export class NgZone {
* });
* ```
*/
run(fn): any {
run(fn: () => any): any {
if (this._disabled) {
return fn();
} else {
@ -145,7 +145,7 @@ export class NgZone {
* });
* ```
*/
runOutsideAngular(fn): any {
runOutsideAngular(fn: () => any): any {
if (this._disabled) {
return fn();
} else {