diff --git a/packages/animations/browser/src/render/transition_animation_engine.ts b/packages/animations/browser/src/render/transition_animation_engine.ts index e1a1ae0041..dcaeccb4f7 100644 --- a/packages/animations/browser/src/render/transition_animation_engine.ts +++ b/packages/animations/browser/src/render/transition_animation_engine.ts @@ -1310,10 +1310,10 @@ export class TransitionAnimationPlayer implements AnimationPlayer { public markedForDestroy: boolean = false; - readonly queued: boolean = true; - constructor(public namespaceId: string, public triggerName: string, public element: any) {} + get queued() { return this._containsRealPlayer == false; } + setRealPlayer(player: AnimationPlayer) { if (this._containsRealPlayer) return; @@ -1324,7 +1324,6 @@ export class TransitionAnimationPlayer implements AnimationPlayer { }); this._queuedCallbacks = {}; this._containsRealPlayer = true; - (this as{queued: boolean}).queued = false; } getRealPlayer() { return this._player; } diff --git a/packages/common/http/test/jsonp_mock.ts b/packages/common/http/test/jsonp_mock.ts index 872a55626b..c631e0c8fa 100644 --- a/packages/common/http/test/jsonp_mock.ts +++ b/packages/common/http/test/jsonp_mock.ts @@ -41,4 +41,4 @@ export class MockDocument { mockLoad(): void { this.mock !.listeners.load !(null as any); } mockError(err: Error) { this.mock !.listeners.error !(err); } -} +} \ No newline at end of file diff --git a/packages/core/src/di/reflective_key.ts b/packages/core/src/di/reflective_key.ts index 2930744fce..bc51fcb649 100644 --- a/packages/core/src/di/reflective_key.ts +++ b/packages/core/src/di/reflective_key.ts @@ -27,11 +27,7 @@ import {resolveForwardRef} from './forward_ref'; * @deprecated No replacement */ export class ReflectiveKey { - /** - * Returns a stringified token. - */ - readonly displayName: string; - + public readonly displayName: string; /** * Private */ diff --git a/packages/core/src/di/reflective_provider.ts b/packages/core/src/di/reflective_provider.ts index 1def0e83c0..1243d8c024 100644 --- a/packages/core/src/di/reflective_provider.ts +++ b/packages/core/src/di/reflective_provider.ts @@ -71,13 +71,11 @@ export interface ResolvedReflectiveProvider { } export class ResolvedReflectiveProvider_ implements ResolvedReflectiveProvider { - readonly resolvedFactory: ResolvedReflectiveFactory; - constructor( public key: ReflectiveKey, public resolvedFactories: ResolvedReflectiveFactory[], - public multiProvider: boolean) { - this.resolvedFactory = this.resolvedFactories[0]; - } + public multiProvider: boolean) {} + + get resolvedFactory(): ResolvedReflectiveFactory { return this.resolvedFactories[0]; } } /** diff --git a/packages/core/src/linker/component_factory_resolver.ts b/packages/core/src/linker/component_factory_resolver.ts index 2ebb7fe369..32c3a8467c 100644 --- a/packages/core/src/linker/component_factory_resolver.ts +++ b/packages/core/src/linker/component_factory_resolver.ts @@ -66,20 +66,13 @@ export class CodegenComponentFactoryResolver implements ComponentFactoryResolver } export class ComponentFactoryBoundToModule extends ComponentFactory { - readonly selector: string; - readonly componentType: Type; - readonly ngContentSelectors: string[]; - readonly inputs: {propName: string, templateName: string}[]; - readonly outputs: {propName: string, templateName: string}[]; + constructor(private factory: ComponentFactory, private ngModule: NgModuleRef) { super(); } - constructor(private factory: ComponentFactory, private ngModule: NgModuleRef) { - super(); - this.selector = factory.selector; - this.componentType = factory.componentType; - this.ngContentSelectors = factory.ngContentSelectors; - this.inputs = factory.inputs; - this.outputs = factory.outputs; - } + 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; } create( injector: Injector, projectableNodes?: any[][], rootSelectorOrNode?: string|any, diff --git a/packages/core/src/linker/query_list.ts b/packages/core/src/linker/query_list.ts index 07edc590e9..34fc10d5b2 100644 --- a/packages/core/src/linker/query_list.ts +++ b/packages/core/src/linker/query_list.ts @@ -41,9 +41,9 @@ export class QueryList/* implements Iterable */ { private _results: Array = []; public readonly changes: Observable = new EventEmitter(); - readonly length: number; - readonly first: T; - readonly last: T; + get length(): number { return this._results.length; } + get first(): T { return this._results[0]; } + get last(): T { return this._results[this.length - 1]; } /** * See @@ -98,9 +98,6 @@ export class QueryList/* implements Iterable */ { reset(res: Array): 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).emit(this); } diff --git a/packages/core/src/view/refs.ts b/packages/core/src/view/refs.ts index 8108cd20fc..27de9521a6 100644 --- a/packages/core/src/view/refs.ts +++ b/packages/core/src/view/refs.ts @@ -478,8 +478,6 @@ class NgModuleRef_ implements NgModuleData, InternalNgModuleRef { /** @internal */ _providers: any[]; - readonly injector: Injector = this; - constructor( private _moduleType: Type, public _parent: Injector, public _bootstrapComponents: Type[], public _def: NgModuleDefinition) { @@ -495,6 +493,8 @@ class NgModuleRef_ implements NgModuleData, InternalNgModuleRef { get componentFactoryResolver() { return this.get(ComponentFactoryResolver); } + get injector(): Injector { return this; } + destroy(): void { if (this._destroyed) { throw new Error( diff --git a/packages/core/src/view/services.ts b/packages/core/src/view/services.ts index c3c973591a..61df5225a7 100644 --- a/packages/core/src/view/services.ts +++ b/packages/core/src/view/services.ts @@ -618,8 +618,9 @@ class DebugRendererFactory2 implements RendererFactory2 { class DebugRenderer2 implements Renderer2 { - readonly data: {[key: string]: any}; - constructor(private delegate: Renderer2) { this.data = this.delegate.data; } + constructor(private delegate: Renderer2) {} + + get data() { return this.delegate.data; } destroyNode(node: any) { removeDebugNodeFromIndex(getDebugNode(node) !); diff --git a/packages/language-service/src/locate_symbol.ts b/packages/language-service/src/locate_symbol.ts index eb634f877a..c1e9a0e161 100644 --- a/packages/language-service/src/locate_symbol.ts +++ b/packages/language-service/src/locate_symbol.ts @@ -171,13 +171,21 @@ 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(); } diff --git a/packages/platform-browser/animations/src/animation_renderer.ts b/packages/platform-browser/animations/src/animation_renderer.ts index b07e45b4fb..9c360da927 100644 --- a/packages/platform-browser/animations/src/animation_renderer.ts +++ b/packages/platform-browser/animations/src/animation_renderer.ts @@ -114,14 +114,13 @@ 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 { diff --git a/packages/platform-browser/src/browser/location/browser_platform_location.ts b/packages/platform-browser/src/browser/location/browser_platform_location.ts index 9bd72bf01b..523ef0b8cf 100644 --- a/packages/platform-browser/src/browser/location/browser_platform_location.ts +++ b/packages/platform-browser/src/browser/location/browser_platform_location.ts @@ -23,10 +23,7 @@ import {supportsState} from './history'; */ @Injectable() export class BrowserPlatformLocation extends PlatformLocation { - readonly location: Location; - readonly search: string; - readonly hash: string; - + public readonly location: Location; private _history: History; constructor(@Inject(DOCUMENT) private _doc: any) { @@ -39,8 +36,6 @@ 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) !; } @@ -54,6 +49,8 @@ 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 { diff --git a/packages/platform-server/src/http.ts b/packages/platform-server/src/http.ts index e9a52d3283..b2ad9bd7b8 100644 --- a/packages/platform-server/src/http.ts +++ b/packages/platform-server/src/http.ts @@ -117,7 +117,6 @@ export class ZoneMacroTaskConnection extends ZoneMacroTaskWrapper; lastConnection: Connection; - readonly readyState: ReadyState; constructor(public request: Request, private backend: XHRBackend) { super(); @@ -127,10 +126,12 @@ export class ZoneMacroTaskConnection extends ZoneMacroTaskWrapper { this.lastConnection = this.backend.createConnection(request); - (this as{readyState: ReadyState}).readyState = - !!this.lastConnection ? this.lastConnection.readyState : ReadyState.Unsent; return this.lastConnection.response as Observable; } + + get readyState(): ReadyState { + return !!this.lastConnection ? this.lastConnection.readyState : ReadyState.Unsent; + } } export class ZoneMacroTaskBackend implements ConnectionBackend { diff --git a/packages/platform-webworker/src/web_workers/worker/platform_location.ts b/packages/platform-webworker/src/web_workers/worker/platform_location.ts index 83ee65443f..4322cad88a 100644 --- a/packages/platform-webworker/src/web_workers/worker/platform_location.ts +++ b/packages/platform-webworker/src/web_workers/worker/platform_location.ts @@ -23,9 +23,6 @@ export class WebWorkerPlatformLocation extends PlatformLocation { public initialized: Promise; private initializedResolve: () => void; - readonly search: string; - readonly hash: string; - constructor( brokerFactory: ClientMessageBrokerFactory, bus: MessageBus, private _serializer: Serializer) { super(); @@ -45,7 +42,7 @@ export class WebWorkerPlatformLocation extends PlatformLocation { if (listeners) { // There was a popState or hashChange event, so the location object thas been updated - this._setLocation(this._serializer.deserialize(msg['location'], LocationType)); + this._location = this._serializer.deserialize(msg['location'], LocationType); listeners.forEach((fn: Function) => fn(msg['event'])); } } @@ -60,7 +57,7 @@ export class WebWorkerPlatformLocation extends PlatformLocation { return this._broker.runOnService(args, LocationType) !.then( (val: LocationType) => { - this._setLocation(val); + this._location = val; this.initializedResolve(); return true; }, @@ -78,6 +75,10 @@ export class WebWorkerPlatformLocation extends PlatformLocation { get pathname(): string { return this._location ? this._location.pathname ! : ''; } + get search(): string { return this._location ? this._location.search : ''; } + + get hash(): string { return this._location ? this._location.hash : ''; } + set pathname(newPath: string) { if (this._location === null) { throw new Error('Attempt to set pathname before value is obtained from UI'); @@ -90,12 +91,6 @@ 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 : ''; - (this as{hash: string}).hash = this._location ? this._location.hash : ''; - } - pushState(state: any, title: string, url: string): void { const fnArgs = [ new FnArg(state, SerializerTypes.PRIMITIVE), diff --git a/packages/router/src/pre_activation.ts b/packages/router/src/pre_activation.ts index bad6aa8dbf..b247d58ed8 100644 --- a/packages/router/src/pre_activation.ts +++ b/packages/router/src/pre_activation.ts @@ -26,10 +26,8 @@ import {andObservables, forEach, shallowEqual, wrapIntoObservable} from './utils import {TreeNode, nodeChildrenAsMap} from './utils/tree'; class CanActivate { - readonly route: ActivatedRouteSnapshot; - constructor(public path: ActivatedRouteSnapshot[]) { - this.route = this.path[this.path.length - 1]; - } + constructor(public path: ActivatedRouteSnapshot[]) {} + get route(): ActivatedRouteSnapshot { return this.path[this.path.length - 1]; } } class CanDeactivate {