chore: Make field declarations explicit
This used to be valid code: ``` class Foo { constructor() { this.bar = ‘string’; } } ``` This will now fail since ‘bar’ is not explicitly defined as a field. We now have to write: ``` class Foo { bar:string; // << REQUIRED constructor() { this.bar = ‘string’; } } ```
This commit is contained in:
@ -9,6 +9,7 @@ import {CONST} from "facade/lang";
|
||||
*
|
||||
*/
|
||||
export class Inject {
|
||||
token;
|
||||
@CONST()
|
||||
constructor(token) {
|
||||
this.token = token;
|
||||
@ -26,6 +27,7 @@ export class Inject {
|
||||
*
|
||||
*/
|
||||
export class InjectPromise {
|
||||
token;
|
||||
@CONST()
|
||||
constructor(token) {
|
||||
this.token = token;
|
||||
@ -43,6 +45,7 @@ export class InjectPromise {
|
||||
*
|
||||
*/
|
||||
export class InjectLazy {
|
||||
token;
|
||||
@CONST()
|
||||
constructor(token) {
|
||||
this.token = token;
|
||||
|
@ -4,9 +4,10 @@ import {reflector} from './reflector';
|
||||
import {Key} from './key';
|
||||
|
||||
export class Dependency {
|
||||
@FIELD('final key:Key')
|
||||
@FIELD('final asPromise:bool')
|
||||
@FIELD('final lazy:bool')
|
||||
key:Key;
|
||||
asPromise:boolean;
|
||||
lazy:boolean;
|
||||
properties:List;
|
||||
constructor(key:Key, asPromise:boolean, lazy:boolean, properties:List) {
|
||||
this.key = key;
|
||||
this.asPromise = asPromise;
|
||||
@ -16,6 +17,11 @@ export class Dependency {
|
||||
}
|
||||
|
||||
export class Binding {
|
||||
key:Key;
|
||||
factory:Function;
|
||||
dependencies:List;
|
||||
providedAsPromise:boolean;
|
||||
|
||||
constructor(key:Key, factory:Function, dependencies:List, providedAsPromise:boolean) {
|
||||
this.key = key;
|
||||
this.factory = factory;
|
||||
@ -29,6 +35,7 @@ export function bind(token):BindingBuilder {
|
||||
}
|
||||
|
||||
export class BindingBuilder {
|
||||
token;
|
||||
constructor(token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
@ -28,6 +28,9 @@ function constructResolvingPath(keys:List) {
|
||||
export class KeyMetadataError extends Error {}
|
||||
|
||||
export class ProviderError extends Error {
|
||||
keys:List;
|
||||
constructResolvingMessage:Function;
|
||||
message;
|
||||
constructor(key:Key, constructResolvingMessage:Function) {
|
||||
this.keys = [key];
|
||||
this.constructResolvingMessage = constructResolvingMessage;
|
||||
@ -82,6 +85,7 @@ export class InstantiationError extends ProviderError {
|
||||
}
|
||||
|
||||
export class InvalidBindingError extends Error {
|
||||
message:string;
|
||||
constructor(binding) {
|
||||
this.message = `Invalid binding ${binding}`;
|
||||
}
|
||||
@ -92,6 +96,7 @@ export class InvalidBindingError extends Error {
|
||||
}
|
||||
|
||||
export class NoAnnotationError extends Error {
|
||||
message:string;
|
||||
constructor(typeOrFunc) {
|
||||
this.message = `Cannot resolve all parameters for ${stringify(typeOrFunc)}`;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import {reflector} from './reflector';
|
||||
var _constructing = new Object();
|
||||
|
||||
class _Waiting {
|
||||
promise:Promise;
|
||||
constructor(promise:Promise) {
|
||||
this.promise = promise;
|
||||
}
|
||||
@ -20,6 +21,12 @@ function _isWaiting(obj):boolean {
|
||||
|
||||
|
||||
export class Injector {
|
||||
_bindings:List;
|
||||
_instances:List;
|
||||
_parent:Injector;
|
||||
_defaultBindings:boolean;
|
||||
_asyncStrategy: _AsyncInjectorStrategy;
|
||||
_syncStrategy:_SyncInjectorStrategy;
|
||||
constructor(bindings:List, {parent=null, defaultBindings=false}={}) {
|
||||
var flatten = _flattenBindings(bindings, MapWrapper.create());
|
||||
this._bindings = this._createListOfBindings(flatten);
|
||||
@ -116,6 +123,7 @@ export class Injector {
|
||||
|
||||
|
||||
class _SyncInjectorStrategy {
|
||||
injector:Injector;
|
||||
constructor(injector:Injector) {
|
||||
this.injector = injector;
|
||||
}
|
||||
@ -163,6 +171,7 @@ class _SyncInjectorStrategy {
|
||||
|
||||
|
||||
class _AsyncInjectorStrategy {
|
||||
injector:Injector;
|
||||
constructor(injector:Injector) {
|
||||
this.injector = injector;
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ import {MapWrapper, Map} from 'facade/collection';
|
||||
import {FIELD, int, isPresent} from 'facade/lang';
|
||||
|
||||
export class Key {
|
||||
@FIELD('final token')
|
||||
@FIELD('final id:int')
|
||||
@FIELD('metadata:Object')
|
||||
token;
|
||||
id:int;
|
||||
metadata:any;
|
||||
constructor(token, id:int) {
|
||||
this.token = token;
|
||||
this.id = id;
|
||||
@ -30,7 +30,7 @@ export class Key {
|
||||
}
|
||||
|
||||
export class KeyRegistry {
|
||||
@FIELD('final _allKeys:Map')
|
||||
_allKeys:Map;
|
||||
constructor() {
|
||||
this._allKeys = MapWrapper.create();
|
||||
}
|
||||
|
Reference in New Issue
Block a user