refactor(core): Change `abstract get` to `readonly` (#19226)

This commit is contained in:
tinayuangao 2017-09-29 00:36:13 +08:00 committed by Victor Berchet
parent 2d2300e118
commit 3aa3d5c548
13 changed files with 73 additions and 73 deletions

View File

@ -34,9 +34,9 @@ export abstract class PlatformLocation {
abstract onPopState(fn: LocationChangeListener): void;
abstract onHashChange(fn: LocationChangeListener): void;
abstract get pathname(): string;
abstract get search(): string;
abstract get hash(): string;
readonly pathname: string;
readonly search: string;
readonly hash: string;
abstract replaceState(state: any, title: string, url: string): void;

View File

@ -163,7 +163,7 @@ export abstract class ReflectiveInjector implements Injector {
* expect(child.parent).toBe(parent);
* ```
*/
abstract get parent(): Injector|null;
readonly parent: Injector|null;
/**
* Resolves an array of providers and creates a child injector from those providers.

View File

@ -26,32 +26,32 @@ export abstract class ComponentRef<C> {
/**
* Location of the Host Element of this Component Instance.
*/
abstract get location(): ElementRef;
readonly location: ElementRef;
/**
* The injector on which the component instance exists.
*/
abstract get injector(): Injector;
readonly injector: Injector;
/**
* The instance of the Component.
*/
abstract get instance(): C;
readonly instance: C;
/**
* The {@link ViewRef} of the Host View of this Component instance.
*/
abstract get hostView(): ViewRef;
readonly hostView: ViewRef;
/**
* The {@link ChangeDetectorRef} of the Component instance.
*/
abstract get changeDetectorRef(): ChangeDetectorRef;
readonly changeDetectorRef: ChangeDetectorRef;
/**
* The component type.
*/
abstract get componentType(): Type<any>;
readonly componentType: Type<any>;
/**
* Destroys the component instance and all of the data structures associated with it.
@ -68,20 +68,20 @@ export abstract class ComponentRef<C> {
* @stable
*/
export abstract class ComponentFactory<C> {
abstract get selector(): string;
abstract get componentType(): Type<any>;
readonly selector: string;
readonly componentType: Type<any>;
/**
* selector for all <ng-content> elements in the component.
*/
abstract get ngContentSelectors(): string[];
readonly ngContentSelectors: string[];
/**
* the inputs of the component.
*/
abstract get inputs(): {propName: string, templateName: string}[];
readonly inputs: {propName: string, templateName: string}[];
/**
* the outputs of the component.
*/
abstract get outputs(): {propName: string, templateName: string}[];
readonly outputs: {propName: string, templateName: string}[];
/**
* Creates a new component.
*/

View File

@ -24,18 +24,18 @@ export abstract class NgModuleRef<T> {
/**
* The injector that contains all of the providers of the NgModule.
*/
abstract get injector(): Injector;
readonly injector: Injector;
/**
* The ComponentFactoryResolver to get hold of the ComponentFactories
* declared in the `entryComponents` property of the module.
*/
abstract get componentFactoryResolver(): ComponentFactoryResolver;
readonly componentFactoryResolver: ComponentFactoryResolver;
/**
* The NgModule instance.
*/
abstract get instance(): T;
readonly instance: T;
/**
* Destroys the module instance and all of the data structures associated with it.
@ -58,6 +58,6 @@ export interface InternalNgModuleRef<T> extends NgModuleRef<T> {
* @experimental
*/
export abstract class NgModuleFactory<T> {
abstract get moduleType(): Type<T>;
readonly moduleType: Type<T>;
abstract create(parentInjector: Injector|null): NgModuleRef<T>;
}

View File

@ -36,7 +36,7 @@ export abstract class TemplateRef<C> {
*
*/
// TODO(i): rename to anchor or location
abstract get elementRef(): ElementRef;
readonly elementRef: ElementRef;
abstract createEmbeddedView(context: C): EmbeddedViewRef<C>;
}

View File

@ -37,11 +37,11 @@ export abstract class ViewContainerRef {
* Anchor element that specifies the location of this container in the containing View.
* <!-- TODO: rename to anchorElement -->
*/
abstract get element(): ElementRef;
readonly element: ElementRef;
abstract get injector(): Injector;
readonly injector: Injector;
abstract get parentInjector(): Injector;
readonly parentInjector: Injector;
/**
* Destroys all Views in this container.
@ -56,7 +56,7 @@ export abstract class ViewContainerRef {
/**
* Returns the number of Views currently attached to this container.
*/
abstract get length(): number;
readonly length: number;
/**
* Instantiates an Embedded View based on the {@link TemplateRef `templateRef`} and inserts it

View File

@ -19,7 +19,7 @@ export abstract class ViewRef extends ChangeDetectorRef {
*/
abstract destroy(): void;
abstract get destroyed(): boolean;
readonly destroyed: boolean;
abstract onDestroy(callback: Function): any /** TODO #9100 */;
}
@ -79,9 +79,9 @@ export abstract class ViewRef extends ChangeDetectorRef {
* @experimental
*/
export abstract class EmbeddedViewRef<C> extends ViewRef {
abstract get context(): C;
readonly context: C;
abstract get rootNodes(): any[];
readonly rootNodes: any[];
}
export interface InternalViewRef extends ViewRef {

View File

@ -23,12 +23,12 @@ export class RenderComponentType {
* @deprecated Debug info is handeled internally in the view engine now.
*/
export abstract class RenderDebugInfo {
abstract get injector(): Injector;
abstract get component(): any;
abstract get providerTokens(): any[];
abstract get references(): {[key: string]: any};
abstract get context(): any;
abstract get source(): string;
readonly injector: Injector;
readonly component: any;
readonly providerTokens: any[];
readonly references: {[key: string]: any};
readonly context: any;
readonly source: string;
}
/**
@ -149,7 +149,7 @@ export abstract class Renderer2 {
* This field can be used to store arbitrary data on this renderer instance.
* This is useful for renderers that delegate to other renderers.
*/
abstract get data(): {[key: string]: any};
readonly data: {[key: string]: any};
abstract destroy(): void;
abstract createElement(name: string, namespace?: string|null): any;

View File

@ -479,15 +479,15 @@ export interface RootData {
}
export abstract class DebugContext {
abstract get view(): ViewData;
abstract get nodeIndex(): number|null;
abstract get injector(): Injector;
abstract get component(): any;
abstract get providerTokens(): any[];
abstract get references(): {[key: string]: any};
abstract get context(): any;
abstract get componentRenderElement(): any;
abstract get renderNode(): any;
readonly view: ViewData;
readonly nodeIndex: number|null;
readonly injector: Injector;
readonly component: any;
readonly providerTokens: any[];
readonly references: {[key: string]: any};
readonly context: any;
readonly componentRenderElement: any;
readonly renderNode: any;
abstract logError(console: Console, ...values: any[]): void;
}

View File

@ -23,7 +23,7 @@ export abstract class AbstractControlDirective {
* that backs this directive. Most properties fall through to that
* instance.
*/
abstract get control(): AbstractControl|null;
readonly control: AbstractControl|null;
/** The value of the control. */
get value(): any { return this.control ? this.control.value : null; }

View File

@ -392,9 +392,9 @@ export declare class PercentPipe implements PipeTransform {
/** @stable */
export declare abstract class PlatformLocation {
readonly abstract hash: string;
readonly abstract pathname: string;
readonly abstract search: string;
readonly hash: string;
readonly pathname: string;
readonly search: string;
abstract back(): void;
abstract forward(): void;
abstract getBaseHrefFromDOM(): string;

View File

@ -213,17 +213,17 @@ export interface ComponentDecorator {
/** @stable */
export declare abstract class ComponentFactory<C> {
readonly abstract componentType: Type<any>;
readonly abstract inputs: {
readonly componentType: Type<any>;
readonly inputs: {
propName: string;
templateName: string;
}[];
readonly abstract ngContentSelectors: string[];
readonly abstract outputs: {
readonly ngContentSelectors: string[];
readonly outputs: {
propName: string;
templateName: string;
}[];
readonly abstract selector: string;
readonly selector: string;
abstract create(injector: Injector, projectableNodes?: any[][], rootSelectorOrNode?: string | any, ngModule?: NgModuleRef<any>): ComponentRef<C>;
}
@ -235,12 +235,12 @@ export declare abstract class ComponentFactoryResolver {
/** @stable */
export declare abstract class ComponentRef<C> {
readonly abstract changeDetectorRef: ChangeDetectorRef;
readonly abstract componentType: Type<any>;
readonly abstract hostView: ViewRef;
readonly abstract injector: Injector;
readonly abstract instance: C;
readonly abstract location: ElementRef;
readonly changeDetectorRef: ChangeDetectorRef;
readonly componentType: Type<any>;
readonly hostView: ViewRef;
readonly injector: Injector;
readonly instance: C;
readonly location: ElementRef;
abstract destroy(): void;
abstract onDestroy(callback: Function): void;
}
@ -369,8 +369,8 @@ export declare class ElementRef {
/** @experimental */
export declare abstract class EmbeddedViewRef<C> extends ViewRef {
readonly abstract context: C;
readonly abstract rootNodes: any[];
readonly context: C;
readonly rootNodes: any[];
}
/** @stable */
@ -597,7 +597,7 @@ export declare const NgModule: NgModuleDecorator;
/** @experimental */
export declare abstract class NgModuleFactory<T> {
readonly abstract moduleType: Type<T>;
readonly moduleType: Type<T>;
abstract create(parentInjector: Injector | null): NgModuleRef<T>;
}
@ -608,9 +608,9 @@ export declare abstract class NgModuleFactoryLoader {
/** @stable */
export declare abstract class NgModuleRef<T> {
readonly abstract componentFactoryResolver: ComponentFactoryResolver;
readonly abstract injector: Injector;
readonly abstract instance: T;
readonly componentFactoryResolver: ComponentFactoryResolver;
readonly injector: Injector;
readonly instance: T;
abstract destroy(): void;
abstract onDestroy(callback: () => void): void;
}
@ -738,7 +738,7 @@ export declare class QueryList<T> {
/** @deprecated */
export declare abstract class ReflectiveInjector implements Injector {
readonly abstract parent: Injector | null;
readonly parent: Injector | null;
abstract createChildFromResolved(providers: ResolvedReflectiveProvider[]): ReflectiveInjector;
abstract get(token: any, notFoundValue?: any): any;
abstract instantiateResolved(provider: ResolvedReflectiveProvider): any;
@ -795,7 +795,7 @@ export declare abstract class Renderer {
/** @experimental */
export declare abstract class Renderer2 {
readonly abstract data: {
readonly data: {
[key: string]: any;
};
destroyNode: ((node: any) => void) | null;
@ -953,7 +953,7 @@ export declare abstract class SystemJsNgModuleLoaderConfig {
/** @stable */
export declare abstract class TemplateRef<C> {
readonly abstract elementRef: ElementRef;
readonly elementRef: ElementRef;
abstract createEmbeddedView(context: C): EmbeddedViewRef<C>;
}
@ -1057,10 +1057,10 @@ export interface ViewChildrenDecorator {
/** @stable */
export declare abstract class ViewContainerRef {
readonly abstract element: ElementRef;
readonly abstract injector: Injector;
readonly abstract length: number;
readonly abstract parentInjector: Injector;
readonly element: ElementRef;
readonly injector: Injector;
readonly length: number;
readonly parentInjector: Injector;
abstract clear(): void;
abstract createComponent<C>(componentFactory: ComponentFactory<C>, index?: number, injector?: Injector, projectableNodes?: any[][], ngModule?: NgModuleRef<any>): ComponentRef<C>;
abstract createEmbeddedView<C>(templateRef: TemplateRef<C>, context?: C, index?: number): EmbeddedViewRef<C>;
@ -1081,7 +1081,7 @@ export declare enum ViewEncapsulation {
/** @stable */
export declare abstract class ViewRef extends ChangeDetectorRef {
readonly abstract destroyed: boolean;
readonly destroyed: boolean;
abstract destroy(): void;
abstract onDestroy(callback: Function): any;
}

View File

@ -65,7 +65,7 @@ export declare abstract class AbstractControl {
/** @stable */
export declare abstract class AbstractControlDirective {
readonly abstract control: AbstractControl | null;
readonly control: AbstractControl | null;
readonly dirty: boolean | null;
readonly disabled: boolean | null;
readonly enabled: boolean | null;