refactor(core): Removed readonly getters and changed to readonly (#19225)
variables
This commit is contained in:
parent
3aa3d5c548
commit
2b84b86fc0
|
@ -1310,9 +1310,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;
|
||||
|
@ -1324,6 +1324,7 @@ export class TransitionAnimationPlayer implements AnimationPlayer {
|
|||
});
|
||||
this._queuedCallbacks = {};
|
||||
this._containsRealPlayer = true;
|
||||
(this as{queued: boolean}).queued = false;
|
||||
}
|
||||
|
||||
getRealPlayer() { return this._player; }
|
||||
|
|
|
@ -41,4 +41,4 @@ export class MockDocument {
|
|||
mockLoad(): void { this.mock !.listeners.load !(null as any); }
|
||||
|
||||
mockError(err: Error) { this.mock !.listeners.error !(err); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,11 @@ import {resolveForwardRef} from './forward_ref';
|
|||
* @deprecated No replacement
|
||||
*/
|
||||
export class ReflectiveKey {
|
||||
public readonly displayName: string;
|
||||
/**
|
||||
* Returns a stringified token.
|
||||
*/
|
||||
readonly displayName: string;
|
||||
|
||||
/**
|
||||
* Private
|
||||
*/
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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); }
|
||||
|
|
|
@ -478,6 +478,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) {
|
||||
|
@ -493,8 +495,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(
|
||||
|
|
|
@ -618,9 +618,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) !);
|
||||
|
|
|
@ -171,21 +171,13 @@ function invertMap(obj: {[name: string]: string}): {[name: string]: string} {
|
|||
class OverrideKindSymbol implements Symbol {
|
||||
public readonly kind: string;
|
||||
constructor(private sym: Symbol, kindOverride: string) { this.kind = kindOverride; }
|
||||
|
||||
get name(): string { return this.sym.name; }
|
||||
|
||||
get language(): string { return this.sym.language; }
|
||||
|
||||
get type(): Symbol|undefined { return this.sym.type; }
|
||||
|
||||
get container(): Symbol|undefined { return this.sym.container; }
|
||||
|
||||
get public(): boolean { return this.sym.public; }
|
||||
|
||||
get callable(): boolean { return this.sym.callable; }
|
||||
|
||||
get nullable(): boolean { return this.sym.nullable; }
|
||||
|
||||
get definition(): Definition { return this.sym.definition; }
|
||||
|
||||
members() { return this.sym.members(); }
|
||||
|
|
|
@ -114,13 +114,14 @@ export class AnimationRendererFactory implements RendererFactory2 {
|
|||
}
|
||||
|
||||
export class BaseAnimationRenderer implements Renderer2 {
|
||||
readonly data: {[key: string]: any};
|
||||
|
||||
constructor(
|
||||
protected namespaceId: string, public delegate: Renderer2, public engine: AnimationEngine) {
|
||||
this.destroyNode = this.delegate.destroyNode ? (n) => delegate.destroyNode !(n) : null;
|
||||
this.data = delegate.data;
|
||||
}
|
||||
|
||||
get data() { return this.delegate.data; }
|
||||
|
||||
destroyNode: ((n: any) => void)|null;
|
||||
|
||||
destroy(): void {
|
||||
|
|
|
@ -23,7 +23,10 @@ import {supportsState} from './history';
|
|||
*/
|
||||
@Injectable()
|
||||
export class BrowserPlatformLocation extends PlatformLocation {
|
||||
public readonly location: Location;
|
||||
readonly location: Location;
|
||||
readonly search: string;
|
||||
readonly hash: string;
|
||||
|
||||
private _history: History;
|
||||
|
||||
constructor(@Inject(DOCUMENT) private _doc: any) {
|
||||
|
@ -36,6 +39,8 @@ export class BrowserPlatformLocation extends PlatformLocation {
|
|||
_init() {
|
||||
(this as{location: Location}).location = getDOM().getLocation();
|
||||
this._history = getDOM().getHistory();
|
||||
(this as{hash: string}).hash = this.location.hash;
|
||||
(this as{search: string}).search = this.location.search;
|
||||
}
|
||||
|
||||
getBaseHrefFromDOM(): string { return getDOM().getBaseHref(this._doc) !; }
|
||||
|
@ -49,8 +54,6 @@ export class BrowserPlatformLocation extends PlatformLocation {
|
|||
}
|
||||
|
||||
get pathname(): string { return this.location.pathname; }
|
||||
get search(): string { return this.location.search; }
|
||||
get hash(): string { return this.location.hash; }
|
||||
set pathname(newPath: string) { this.location.pathname = newPath; }
|
||||
|
||||
pushState(state: any, title: string, url: string): void {
|
||||
|
|
|
@ -117,6 +117,7 @@ export class ZoneMacroTaskConnection extends ZoneMacroTaskWrapper<Request, Respo
|
|||
Connection {
|
||||
response: Observable<Response>;
|
||||
lastConnection: Connection;
|
||||
readonly readyState: ReadyState;
|
||||
|
||||
constructor(public request: Request, private backend: XHRBackend) {
|
||||
super();
|
||||
|
@ -126,12 +127,10 @@ export class ZoneMacroTaskConnection extends ZoneMacroTaskWrapper<Request, Respo
|
|||
|
||||
delegate(request: Request): Observable<Response> {
|
||||
this.lastConnection = this.backend.createConnection(request);
|
||||
(this as{readyState: ReadyState}).readyState =
|
||||
!!this.lastConnection ? this.lastConnection.readyState : ReadyState.Unsent;
|
||||
return this.lastConnection.response as Observable<Response>;
|
||||
}
|
||||
|
||||
get readyState(): ReadyState {
|
||||
return !!this.lastConnection ? this.lastConnection.readyState : ReadyState.Unsent;
|
||||
}
|
||||
}
|
||||
|
||||
export class ZoneMacroTaskBackend implements ConnectionBackend {
|
||||
|
|
|
@ -23,6 +23,9 @@ export class WebWorkerPlatformLocation extends PlatformLocation {
|
|||
public initialized: Promise<any>;
|
||||
private initializedResolve: () => void;
|
||||
|
||||
readonly search: string;
|
||||
readonly hash: string;
|
||||
|
||||
constructor(
|
||||
brokerFactory: ClientMessageBrokerFactory, bus: MessageBus, private _serializer: Serializer) {
|
||||
super();
|
||||
|
@ -42,7 +45,7 @@ export class WebWorkerPlatformLocation extends PlatformLocation {
|
|||
|
||||
if (listeners) {
|
||||
// There was a popState or hashChange event, so the location object thas been updated
|
||||
this._location = this._serializer.deserialize(msg['location'], LocationType);
|
||||
this._setLocation(this._serializer.deserialize(msg['location'], LocationType));
|
||||
listeners.forEach((fn: Function) => fn(msg['event']));
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +60,7 @@ export class WebWorkerPlatformLocation extends PlatformLocation {
|
|||
|
||||
return this._broker.runOnService(args, LocationType) !.then(
|
||||
(val: LocationType) => {
|
||||
this._location = val;
|
||||
this._setLocation(val);
|
||||
this.initializedResolve();
|
||||
return true;
|
||||
},
|
||||
|
@ -75,10 +78,6 @@ export class WebWorkerPlatformLocation extends PlatformLocation {
|
|||
|
||||
get pathname(): string { return this._location ? this._location.pathname ! : '<unknown>'; }
|
||||
|
||||
get search(): string { return this._location ? this._location.search : '<unknown>'; }
|
||||
|
||||
get hash(): string { return this._location ? this._location.hash : '<unknown>'; }
|
||||
|
||||
set pathname(newPath: string) {
|
||||
if (this._location === null) {
|
||||
throw new Error('Attempt to set pathname before value is obtained from UI');
|
||||
|
@ -91,6 +90,12 @@ export class WebWorkerPlatformLocation extends PlatformLocation {
|
|||
this._broker.runOnService(args, null);
|
||||
}
|
||||
|
||||
private _setLocation(location: LocationType) {
|
||||
this._location = location;
|
||||
(this as{search: string}).search = this._location ? this._location.search : '<unknown>';
|
||||
(this as{hash: string}).hash = this._location ? this._location.hash : '<unknown>';
|
||||
}
|
||||
|
||||
pushState(state: any, title: string, url: string): void {
|
||||
const fnArgs = [
|
||||
new FnArg(state, SerializerTypes.PRIMITIVE),
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue