From df09a7c817143901e05c4bdd09bda30ff8f9cef3 Mon Sep 17 00:00:00 2001 From: vsavkin Date: Tue, 7 Oct 2014 09:37:45 -0400 Subject: [PATCH] refactor(injector): add bool and int annotations --- modules/di/src/binding.js | 4 ++-- modules/di/src/injector.js | 6 +++--- modules/di/src/key.js | 7 ++++--- modules/di/src/reflector.es6 | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/di/src/binding.js b/modules/di/src/binding.js index 56b7ba7988..c07f6cde73 100644 --- a/modules/di/src/binding.js +++ b/modules/di/src/binding.js @@ -1,10 +1,10 @@ -import {Type} from 'facade/lang'; +import {Type, bool} from 'facade/lang'; import {List, MapWrapper, ListWrapper} from 'facade/collection'; import {Reflector} from './reflector'; import {Key, Dependency} from './key'; export class Binding { - constructor(key:Key, factory:Function, dependencies:List, providedAsFuture) { + constructor(key:Key, factory:Function, dependencies:List, providedAsFuture:bool) { this.key = key; this.factory = factory; this.dependencies = dependencies; diff --git a/modules/di/src/injector.js b/modules/di/src/injector.js index 560f6b93c6..642fc7f8fc 100644 --- a/modules/di/src/injector.js +++ b/modules/di/src/injector.js @@ -2,7 +2,7 @@ import {Map, List, MapWrapper, ListWrapper} from 'facade/collection'; import {Binding, BindingBuilder, bind} from './binding'; import {ProviderError, NoProviderError, InvalidBindingError, AsyncBindingError, CyclicDependencyError, InstantiationError} from './exceptions'; -import {Type, isPresent, isBlank} from 'facade/lang'; +import {Type, isPresent, isBlank, bool} from 'facade/lang'; import {Future, FutureWrapper} from 'facade/async'; import {Key} from './key'; @@ -13,7 +13,7 @@ class _Waiting { this.future = future; } } -function _isWaiting(obj) { +function _isWaiting(obj):bool { return obj instanceof _Waiting; } @@ -62,7 +62,7 @@ export class Injector { return ListWrapper.createFixedSize(Key.numberOfKeys() + 1); } - _getByKey(key:Key, returnFuture, returnLazy) { + _getByKey(key:Key, returnFuture:bool, returnLazy:bool) { if (returnLazy) { return () => this._getByKey(key, returnFuture, false); } diff --git a/modules/di/src/key.js b/modules/di/src/key.js index f9b626f5cb..442a41a118 100644 --- a/modules/di/src/key.js +++ b/modules/di/src/key.js @@ -1,11 +1,12 @@ import {MapWrapper} from 'facade/collection'; +import {int, bool} from 'facade/lang'; var _allKeys = {}; -var _id = 0; +var _id:int = 0; //TODO: vsavkin: move to binding once cyclic deps are supported export class Dependency { - constructor(key:Key, asFuture, lazy){ + constructor(key:Key, asFuture:bool, lazy:bool){ this.key = key; this.asFuture = asFuture; this.lazy = lazy; @@ -13,7 +14,7 @@ export class Dependency { } export class Key { - constructor(token, id) { + constructor(token, id:int) { this.token = token; this.id = id; } diff --git a/modules/di/src/reflector.es6 b/modules/di/src/reflector.es6 index 5c30839446..ec6db41bc9 100644 --- a/modules/di/src/reflector.es6 +++ b/modules/di/src/reflector.es6 @@ -38,7 +38,7 @@ export class Reflector { } if (isPresent(type)) { - return this._createDependency(type, false); + return this._createDependency(type, false, false); } else { throw new NoAnnotationError(constructedType); }