feat(build): require parameter types

Fixes #2833
This commit is contained in:
Alex Eagle
2015-07-21 06:20:13 -07:00
parent 6d760666a9
commit de18da2a0d
81 changed files with 379 additions and 290 deletions
+3 -3
View File
@@ -309,13 +309,13 @@ export class BindingBuilder {
* expect(injector.get(String)).toEqual('Hello');
* ```
*/
toValue(value): Binding { return new Binding(this.token, {toValue: value}); }
toValue(value: any): Binding { return new Binding(this.token, {toValue: value}); }
/**
* Binds a key to the alias for an existing key.
*
* An alias means that we will return the same instance as if the alias token was used. (This is
* in contrast to `toClass` where a separet instance of `toClass` will be returned.)
* in contrast to `toClass` where a separate instance of `toClass` will be returned.)
*
* ## Example
*
@@ -344,7 +344,7 @@ export class BindingBuilder {
* expect(injectorClass.get(Vehicle) instanceof Car).toBe(true);
* ```
*/
toAlias(aliasToken): Binding {
toAlias(aliasToken: /*Type*/ any): Binding {
if (isBlank(aliasToken)) {
throw new BaseException(`Can not alias ${stringify(this.token)} to a blank value!`);
}
+1 -1
View File
@@ -42,7 +42,7 @@ export class AbstractBindingError extends BaseException {
}
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
addKey(key): void {
addKey(key: any): void {
this.keys.push(key);
this.message = this.constructResolvingMessage(this.keys);
}
+2 -2
View File
@@ -480,7 +480,7 @@ export class Injector {
*binding).
* @returns an instance represented by the token. Throws if not found.
*/
get(token): any {
get(token: any): any {
return this._getByKey(Key.get(token), DEFAULT_VISIBILITY, false, PUBLIC_AND_PRIVATE);
}
@@ -490,7 +490,7 @@ export class Injector {
* @param `token`: usually a `Type`. (Same as the token used while setting up a binding).
* @returns an instance represented by the token. Returns `null` if not found.
*/
getOptional(token): any {
getOptional(token: any): any {
return this._getByKey(Key.get(token), DEFAULT_VISIBILITY, true, PUBLIC_AND_PRIVATE);
}
+1 -1
View File
@@ -30,7 +30,7 @@ export class Key {
/**
* Retrieves a `Key` for a token.
*/
static get(token): Key { return _globalKeyRegistry.get(resolveForwardRef(token)); }
static get(token: Object): Key { return _globalKeyRegistry.get(resolveForwardRef(token)); }
/**
* @returns the number of keys registered in the system.