refactor(core): Removed readonly getters and changed to readonly (#19842)

variables

PR Close #19842
This commit is contained in:
Yuan Gao 2017-09-15 16:12:02 -07:00 committed by Jason Aden
parent c9ad529afc
commit e544742156
8 changed files with 37 additions and 24 deletions

View File

@ -1389,9 +1389,9 @@ export class TransitionAnimationPlayer implements AnimationPlayer {
public markedForDestroy: boolean = false;
constructor(public namespaceId: string, public triggerName: string, public element: any) {}
readonly queued: boolean = true;
get queued() { return this._containsRealPlayer == false; }
constructor(public namespaceId: string, public triggerName: string, public element: any) {}
setRealPlayer(player: AnimationPlayer) {
if (this._containsRealPlayer) return;
@ -1403,6 +1403,7 @@ export class TransitionAnimationPlayer implements AnimationPlayer {
});
this._queuedCallbacks = {};
this._containsRealPlayer = true;
(this as{queued: boolean}).queued = false;
}
getRealPlayer() { return this._player; }

View File

@ -23,13 +23,12 @@ export class MockScriptElement {
export class MockDocument {
mock: MockScriptElement|null;
readonly body: any = this;
createElement(tag: 'script'): HTMLScriptElement {
return new MockScriptElement() as any as HTMLScriptElement;
}
get body(): any { return this; }
appendChild(node: any): void { this.mock = node; }
removeNode(node: any): void {
@ -41,4 +40,4 @@ export class MockDocument {
mockLoad(): void { this.mock !.listeners.load !(null as any); }
mockError(err: Error) { this.mock !.listeners.error !(err); }
}
}

View File

@ -71,11 +71,13 @@ export interface ResolvedReflectiveProvider {
}
export class ResolvedReflectiveProvider_ implements ResolvedReflectiveProvider {
readonly resolvedFactory: ResolvedReflectiveFactory;
constructor(
public key: ReflectiveKey, public resolvedFactories: ResolvedReflectiveFactory[],
public multiProvider: boolean) {}
get resolvedFactory(): ResolvedReflectiveFactory { return this.resolvedFactories[0]; }
public multiProvider: boolean) {
this.resolvedFactory = this.resolvedFactories[0];
}
}
/**

View File

@ -66,13 +66,20 @@ export class CodegenComponentFactoryResolver implements ComponentFactoryResolver
}
export class ComponentFactoryBoundToModule<C> extends ComponentFactory<C> {
constructor(private factory: ComponentFactory<C>, private ngModule: NgModuleRef<any>) { super(); }
readonly selector: string;
readonly componentType: Type<any>;
readonly ngContentSelectors: string[];
readonly inputs: {propName: string, templateName: string}[];
readonly outputs: {propName: string, templateName: string}[];
get selector() { return this.factory.selector; }
get componentType() { return this.factory.componentType; }
get ngContentSelectors() { return this.factory.ngContentSelectors; }
get inputs() { return this.factory.inputs; }
get outputs() { return this.factory.outputs; }
constructor(private factory: ComponentFactory<C>, private ngModule: NgModuleRef<any>) {
super();
this.selector = factory.selector;
this.componentType = factory.componentType;
this.ngContentSelectors = factory.ngContentSelectors;
this.inputs = factory.inputs;
this.outputs = factory.outputs;
}
create(
injector: Injector, projectableNodes?: any[][], rootSelectorOrNode?: string|any,

View File

@ -41,9 +41,9 @@ export class QueryList<T>/* implements Iterable<T> */ {
private _results: Array<T> = [];
public readonly changes: Observable<any> = new EventEmitter();
get length(): number { return this._results.length; }
get first(): T { return this._results[0]; }
get last(): T { return this._results[this.length - 1]; }
readonly length: number;
readonly first: T;
readonly last: T;
/**
* See
@ -98,6 +98,9 @@ export class QueryList<T>/* implements Iterable<T> */ {
reset(res: Array<T|any[]>): void {
this._results = flatten(res);
(this as{dirty: boolean}).dirty = false;
(this as{length: number}).length = this._results.length;
(this as{last: T}).last = this._results[this.length - 1];
(this as{first: T}).first = this._results[0];
}
notifyOnChanges(): void { (this.changes as EventEmitter<any>).emit(this); }

View File

@ -481,6 +481,8 @@ class NgModuleRef_ implements NgModuleData, InternalNgModuleRef<any> {
/** @internal */
_providers: any[];
readonly injector: Injector = this;
constructor(
private _moduleType: Type<any>, public _parent: Injector,
public _bootstrapComponents: Type<any>[], public _def: NgModuleDefinition) {
@ -496,8 +498,6 @@ class NgModuleRef_ implements NgModuleData, InternalNgModuleRef<any> {
get componentFactoryResolver() { return this.get(ComponentFactoryResolver); }
get injector(): Injector { return this; }
destroy(): void {
if (this._destroyed) {
throw new Error(

View File

@ -649,9 +649,8 @@ class DebugRendererFactory2 implements RendererFactory2 {
class DebugRenderer2 implements Renderer2 {
constructor(private delegate: Renderer2) {}
get data() { return this.delegate.data; }
readonly data: {[key: string]: any};
constructor(private delegate: Renderer2) { this.data = this.delegate.data; }
destroyNode(node: any) {
removeDebugNodeFromIndex(getDebugNode(node) !);

View File

@ -26,8 +26,10 @@ import {andObservables, forEach, shallowEqual, wrapIntoObservable} from './utils
import {TreeNode, nodeChildrenAsMap} from './utils/tree';
class CanActivate {
constructor(public path: ActivatedRouteSnapshot[]) {}
get route(): ActivatedRouteSnapshot { return this.path[this.path.length - 1]; }
readonly route: ActivatedRouteSnapshot;
constructor(public path: ActivatedRouteSnapshot[]) {
this.route = this.path[this.path.length - 1];
}
}
class CanDeactivate {