cleanup(di): use typescript initialization idioms
This commit is contained in:
parent
1a4ab2c57a
commit
a9ce0f7afb
|
@ -16,13 +16,7 @@ import {NoAnnotationError} from './exceptions';
|
||||||
*/
|
*/
|
||||||
export class Dependency {
|
export class Dependency {
|
||||||
constructor(public key: Key, public asPromise: boolean, public lazy: boolean,
|
constructor(public key: Key, public asPromise: boolean, public lazy: boolean,
|
||||||
public optional: boolean, public properties: List<any>) {
|
public optional: boolean, public properties: List<any>) {}
|
||||||
this.key = key;
|
|
||||||
this.asPromise = asPromise;
|
|
||||||
this.lazy = lazy;
|
|
||||||
this.optional = optional;
|
|
||||||
this.properties = properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
static fromKey(key: Key) { return new Dependency(key, false, false, false, []); }
|
static fromKey(key: Key) { return new Dependency(key, false, false, false, []); }
|
||||||
}
|
}
|
||||||
|
@ -254,33 +248,26 @@ export class Binding {
|
||||||
* @exportedAs angular2/di
|
* @exportedAs angular2/di
|
||||||
*/
|
*/
|
||||||
export class ResolvedBinding {
|
export class ResolvedBinding {
|
||||||
/**
|
constructor(
|
||||||
* A key, usually a `Type`.
|
/**
|
||||||
*/
|
* A key, usually a `Type`.
|
||||||
key: Key;
|
*/
|
||||||
|
public key: Key,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory function which can return an instance of an object represented by a key.
|
* Factory function which can return an instance of an object represented by a key.
|
||||||
*/
|
*/
|
||||||
factory: Function;
|
public factory: Function,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Arguments (dependencies) to the `factory` function.
|
* Arguments (dependencies) to the `factory` function.
|
||||||
*/
|
*/
|
||||||
dependencies: List<Dependency>;
|
public dependencies: List<Dependency>,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies whether the `factory` function returns a `Promise`.
|
* Specifies whether the `factory` function returns a `Promise`.
|
||||||
*/
|
*/
|
||||||
providedAsPromise: boolean;
|
public providedAsPromise: boolean) {}
|
||||||
|
|
||||||
constructor(key: Key, factory: Function, dependencies: List<Dependency>,
|
|
||||||
providedAsPromise: boolean) {
|
|
||||||
this.key = key;
|
|
||||||
this.factory = factory;
|
|
||||||
this.dependencies = dependencies;
|
|
||||||
this.providedAsPromise = providedAsPromise;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -307,9 +294,7 @@ export function bind(token): BindingBuilder {
|
||||||
* @exportedAs angular2/di
|
* @exportedAs angular2/di
|
||||||
*/
|
*/
|
||||||
export class BindingBuilder {
|
export class BindingBuilder {
|
||||||
token;
|
constructor(public token) {}
|
||||||
|
|
||||||
constructor(token) { this.token = token; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds an interface to an implementation / subclass.
|
* Binds an interface to an implementation / subclass.
|
||||||
|
|
Loading…
Reference in New Issue