refactor(abstract): Use abstract keyword where possible to decrease file size. (#14112)
PR Close: #14112
This commit is contained in:
parent
827c3fe199
commit
d339d8b81d
|
@ -15,10 +15,6 @@ import {LifecycleHooks, reflector} from './private_import_core';
|
||||||
import {CssSelector} from './selector';
|
import {CssSelector} from './selector';
|
||||||
import {splitAtColon} from './util';
|
import {splitAtColon} from './util';
|
||||||
|
|
||||||
function unimplemented(): any {
|
|
||||||
throw new Error('unimplemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
// group 0: "[prop] or (event) or @trigger"
|
// group 0: "[prop] or (event) or @trigger"
|
||||||
// group 1: "prop" from "[prop]"
|
// group 1: "prop" from "[prop]"
|
||||||
// group 2: "event" from "(event)"
|
// group 2: "event" from "(event)"
|
||||||
|
|
|
@ -11,10 +11,6 @@ import {MissingTranslationStrategy, ViewEncapsulation, isDevMode} from '@angular
|
||||||
import {CompileIdentifierMetadata} from './compile_metadata';
|
import {CompileIdentifierMetadata} from './compile_metadata';
|
||||||
import {Identifiers, createIdentifier} from './identifiers';
|
import {Identifiers, createIdentifier} from './identifiers';
|
||||||
|
|
||||||
function unimplemented(): any {
|
|
||||||
throw new Error('unimplemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
export class CompilerConfig {
|
export class CompilerConfig {
|
||||||
public renderTypes: RenderTypes;
|
public renderTypes: RenderTypes;
|
||||||
public defaultEncapsulation: ViewEncapsulation;
|
public defaultEncapsulation: ViewEncapsulation;
|
||||||
|
@ -55,12 +51,12 @@ export class CompilerConfig {
|
||||||
* to help tree shaking.
|
* to help tree shaking.
|
||||||
*/
|
*/
|
||||||
export abstract class RenderTypes {
|
export abstract class RenderTypes {
|
||||||
get renderer(): CompileIdentifierMetadata { return unimplemented(); }
|
abstract get renderer(): CompileIdentifierMetadata;
|
||||||
get renderText(): CompileIdentifierMetadata { return unimplemented(); }
|
abstract get renderText(): CompileIdentifierMetadata;
|
||||||
get renderElement(): CompileIdentifierMetadata { return unimplemented(); }
|
abstract get renderElement(): CompileIdentifierMetadata;
|
||||||
get renderComment(): CompileIdentifierMetadata { return unimplemented(); }
|
abstract get renderComment(): CompileIdentifierMetadata;
|
||||||
get renderNode(): CompileIdentifierMetadata { return unimplemented(); }
|
abstract get renderNode(): CompileIdentifierMetadata;
|
||||||
get renderEvent(): CompileIdentifierMetadata { return unimplemented(); }
|
abstract get renderEvent(): CompileIdentifierMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DefaultRenderTypes implements RenderTypes {
|
export class DefaultRenderTypes implements RenderTypes {
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
import {ErrorHandler} from '../src/error_handler';
|
import {ErrorHandler} from '../src/error_handler';
|
||||||
import {ListWrapper} from '../src/facade/collection';
|
import {ListWrapper} from '../src/facade/collection';
|
||||||
import {unimplemented} from '../src/facade/errors';
|
|
||||||
import {stringify} from '../src/facade/lang';
|
import {stringify} from '../src/facade/lang';
|
||||||
import {isPromise} from '../src/util/lang';
|
import {isPromise} from '../src/util/lang';
|
||||||
|
|
||||||
|
@ -185,9 +184,7 @@ export abstract class PlatformRef {
|
||||||
*
|
*
|
||||||
* @experimental APIs related to application bootstrap are currently under review.
|
* @experimental APIs related to application bootstrap are currently under review.
|
||||||
*/
|
*/
|
||||||
bootstrapModuleFactory<M>(moduleFactory: NgModuleFactory<M>): Promise<NgModuleRef<M>> {
|
abstract bootstrapModuleFactory<M>(moduleFactory: NgModuleFactory<M>): Promise<NgModuleRef<M>>;
|
||||||
throw unimplemented();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance of an `@NgModule` for a given platform using the given runtime compiler.
|
* Creates an instance of an `@NgModule` for a given platform using the given runtime compiler.
|
||||||
|
@ -217,14 +214,14 @@ export abstract class PlatformRef {
|
||||||
* Retrieve the platform {@link Injector}, which is the parent injector for
|
* Retrieve the platform {@link Injector}, which is the parent injector for
|
||||||
* every Angular application on the page and provides singleton providers.
|
* every Angular application on the page and provides singleton providers.
|
||||||
*/
|
*/
|
||||||
get injector(): Injector { throw unimplemented(); };
|
abstract get injector(): Injector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy the Angular platform and all Angular applications on the page.
|
* Destroy the Angular platform and all Angular applications on the page.
|
||||||
*/
|
*/
|
||||||
abstract destroy(): void;
|
abstract destroy(): void;
|
||||||
|
|
||||||
get destroyed(): boolean { throw unimplemented(); }
|
abstract get destroyed(): boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _callAndReportToErrorHandler(errorHandler: ErrorHandler, callback: () => any): any {
|
function _callAndReportToErrorHandler(errorHandler: ErrorHandler, callback: () => any): any {
|
||||||
|
@ -381,29 +378,29 @@ export abstract class ApplicationRef {
|
||||||
* Get a list of component types registered to this application.
|
* Get a list of component types registered to this application.
|
||||||
* This list is populated even before the component is created.
|
* This list is populated even before the component is created.
|
||||||
*/
|
*/
|
||||||
get componentTypes(): Type<any>[] { return <Type<any>[]>unimplemented(); };
|
abstract get componentTypes(): Type<any>[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of components registered to this application.
|
* Get a list of components registered to this application.
|
||||||
*/
|
*/
|
||||||
get components(): ComponentRef<any>[] { return <ComponentRef<any>[]>unimplemented(); };
|
abstract get components(): ComponentRef<any>[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attaches a view so that it will be dirty checked.
|
* Attaches a view so that it will be dirty checked.
|
||||||
* The view will be automatically detached when it is destroyed.
|
* The view will be automatically detached when it is destroyed.
|
||||||
* This will throw if the view is already attached to a ViewContainer.
|
* This will throw if the view is already attached to a ViewContainer.
|
||||||
*/
|
*/
|
||||||
attachView(view: ViewRef): void { unimplemented(); }
|
abstract attachView(view: ViewRef): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detaches a view from dirty checking again.
|
* Detaches a view from dirty checking again.
|
||||||
*/
|
*/
|
||||||
detachView(view: ViewRef): void { unimplemented(); }
|
abstract detachView(view: ViewRef): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of attached views.
|
* Returns the number of attached views.
|
||||||
*/
|
*/
|
||||||
get viewCount() { return unimplemented(); }
|
abstract get viewCount(): number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {unimplemented} from '../facade/errors';
|
|
||||||
import {stringify} from '../facade/lang';
|
import {stringify} from '../facade/lang';
|
||||||
import {Type} from '../type';
|
import {Type} from '../type';
|
||||||
|
|
||||||
|
@ -55,10 +54,9 @@ export abstract class Injector {
|
||||||
* Injector.THROW_IF_NOT_FOUND is given
|
* Injector.THROW_IF_NOT_FOUND is given
|
||||||
* - Returns the `notFoundValue` otherwise
|
* - Returns the `notFoundValue` otherwise
|
||||||
*/
|
*/
|
||||||
get<T>(token: Type<T>|InjectionToken<T>, notFoundValue?: T): T;
|
abstract get<T>(token: Type<T>|InjectionToken<T>, notFoundValue?: T): T;
|
||||||
/**
|
/**
|
||||||
* @deprecated from v4.0.0 use Type<T> or InjectToken<T>
|
* @deprecated from v4.0.0 use Type<T> or InjectToken<T>
|
||||||
*/
|
*/
|
||||||
get(token: any, notFoundValue?: any): any;
|
abstract get(token: any, notFoundValue?: any): any;
|
||||||
get(token: any, notFoundValue?: any): any { return unimplemented(); }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {unimplemented} from '../facade/errors';
|
|
||||||
import {Type} from '../type';
|
import {Type} from '../type';
|
||||||
|
|
||||||
import {Injector, THROW_IF_NOT_FOUND} from './injector';
|
import {Injector, THROW_IF_NOT_FOUND} from './injector';
|
||||||
|
@ -467,7 +466,7 @@ export abstract class ReflectiveInjector implements Injector {
|
||||||
* expect(child.parent).toBe(parent);
|
* expect(child.parent).toBe(parent);
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
get parent(): Injector { return unimplemented(); }
|
abstract get parent(): Injector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves an array of providers and creates a child injector from those providers.
|
* Resolves an array of providers and creates a child injector from those providers.
|
||||||
|
@ -496,7 +495,7 @@ export abstract class ReflectiveInjector implements Injector {
|
||||||
* because it needs to resolve the passed-in providers first.
|
* because it needs to resolve the passed-in providers first.
|
||||||
* See {@link Injector#resolve} and {@link Injector#createChildFromResolved}.
|
* See {@link Injector#resolve} and {@link Injector#createChildFromResolved}.
|
||||||
*/
|
*/
|
||||||
resolveAndCreateChild(providers: Provider[]): ReflectiveInjector { return unimplemented(); }
|
abstract resolveAndCreateChild(providers: Provider[]): ReflectiveInjector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a child injector from previously resolved providers.
|
* Creates a child injector from previously resolved providers.
|
||||||
|
@ -549,7 +548,7 @@ export abstract class ReflectiveInjector implements Injector {
|
||||||
* expect(car).not.toBe(injector.resolveAndInstantiate(Car));
|
* expect(car).not.toBe(injector.resolveAndInstantiate(Car));
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
resolveAndInstantiate(provider: Provider): any { return unimplemented(); }
|
abstract resolveAndInstantiate(provider: Provider): any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates an object using a resolved provider in the context of the injector.
|
* Instantiates an object using a resolved provider in the context of the injector.
|
||||||
|
@ -575,7 +574,7 @@ export abstract class ReflectiveInjector implements Injector {
|
||||||
* expect(car).not.toBe(injector.instantiateResolved(carProvider));
|
* expect(car).not.toBe(injector.instantiateResolved(carProvider));
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
instantiateResolved(provider: ResolvedReflectiveProvider): any { return unimplemented(); }
|
abstract instantiateResolved(provider: ResolvedReflectiveProvider): any;
|
||||||
|
|
||||||
abstract get(token: any, notFoundValue?: any): any;
|
abstract get(token: any, notFoundValue?: any): any;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
import {ChangeDetectorRef} from '../change_detection/change_detection';
|
import {ChangeDetectorRef} from '../change_detection/change_detection';
|
||||||
import {Injector} from '../di/injector';
|
import {Injector} from '../di/injector';
|
||||||
import {unimplemented} from '../facade/errors';
|
|
||||||
import {Type} from '../type';
|
import {Type} from '../type';
|
||||||
|
|
||||||
import {ElementRef} from './element_ref';
|
import {ElementRef} from './element_ref';
|
||||||
|
@ -30,32 +29,32 @@ export abstract class ComponentRef<C> {
|
||||||
/**
|
/**
|
||||||
* Location of the Host Element of this Component Instance.
|
* Location of the Host Element of this Component Instance.
|
||||||
*/
|
*/
|
||||||
get location(): ElementRef { return unimplemented(); }
|
abstract get location(): ElementRef;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The injector on which the component instance exists.
|
* The injector on which the component instance exists.
|
||||||
*/
|
*/
|
||||||
get injector(): Injector { return unimplemented(); }
|
abstract get injector(): Injector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The instance of the Component.
|
* The instance of the Component.
|
||||||
*/
|
*/
|
||||||
get instance(): C { return unimplemented(); };
|
abstract get instance(): C;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link ViewRef} of the Host View of this Component instance.
|
* The {@link ViewRef} of the Host View of this Component instance.
|
||||||
*/
|
*/
|
||||||
get hostView(): ViewRef { return unimplemented(); };
|
abstract get hostView(): ViewRef;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link ChangeDetectorRef} of the Component instance.
|
* The {@link ChangeDetectorRef} of the Component instance.
|
||||||
*/
|
*/
|
||||||
get changeDetectorRef(): ChangeDetectorRef { return unimplemented(); }
|
abstract get changeDetectorRef(): ChangeDetectorRef;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The component type.
|
* The component type.
|
||||||
*/
|
*/
|
||||||
get componentType(): Type<any> { return unimplemented(); }
|
abstract get componentType(): Type<any>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroys the component instance and all of the data structures associated with it.
|
* Destroys the component instance and all of the data structures associated with it.
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Injector, THROW_IF_NOT_FOUND} from '../di/injector';
|
import {Injector, THROW_IF_NOT_FOUND} from '../di/injector';
|
||||||
import {unimplemented} from '../facade/errors';
|
|
||||||
import {stringify} from '../facade/lang';
|
import {stringify} from '../facade/lang';
|
||||||
import {Type} from '../type';
|
import {Type} from '../type';
|
||||||
import {ComponentFactory} from './component_factory';
|
import {ComponentFactory} from './component_factory';
|
||||||
|
@ -27,18 +26,18 @@ export abstract class NgModuleRef<T> {
|
||||||
/**
|
/**
|
||||||
* The injector that contains all of the providers of the NgModule.
|
* The injector that contains all of the providers of the NgModule.
|
||||||
*/
|
*/
|
||||||
get injector(): Injector { return unimplemented(); }
|
abstract get injector(): Injector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ComponentFactoryResolver to get hold of the ComponentFactories
|
* The ComponentFactoryResolver to get hold of the ComponentFactories
|
||||||
* declared in the `entryComponents` property of the module.
|
* declared in the `entryComponents` property of the module.
|
||||||
*/
|
*/
|
||||||
get componentFactoryResolver(): ComponentFactoryResolver { return unimplemented(); }
|
abstract get componentFactoryResolver(): ComponentFactoryResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The NgModule instance.
|
* The NgModule instance.
|
||||||
*/
|
*/
|
||||||
get instance(): T { return unimplemented(); }
|
abstract get instance(): T;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroys the module instance and all of the data structures associated with it.
|
* Destroys the module instance and all of the data structures associated with it.
|
||||||
|
|
|
@ -37,7 +37,7 @@ export abstract class TemplateRef<C> {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
// TODO(i): rename to anchor or location
|
// TODO(i): rename to anchor or location
|
||||||
get elementRef(): ElementRef { return null; }
|
abstract get elementRef(): ElementRef;
|
||||||
|
|
||||||
abstract createEmbeddedView(context: C): EmbeddedViewRef<C>;
|
abstract createEmbeddedView(context: C): EmbeddedViewRef<C>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Injector} from '../di/injector';
|
import {Injector} from '../di/injector';
|
||||||
import {unimplemented} from '../facade/errors';
|
|
||||||
import {isPresent} from '../facade/lang';
|
import {isPresent} from '../facade/lang';
|
||||||
import {WtfScopeFn, wtfCreateScope, wtfLeave} from '../profile/profile';
|
import {WtfScopeFn, wtfCreateScope, wtfLeave} from '../profile/profile';
|
||||||
|
|
||||||
|
@ -42,11 +41,11 @@ export abstract class ViewContainerRef {
|
||||||
* Anchor element that specifies the location of this container in the containing View.
|
* Anchor element that specifies the location of this container in the containing View.
|
||||||
* <!-- TODO: rename to anchorElement -->
|
* <!-- TODO: rename to anchorElement -->
|
||||||
*/
|
*/
|
||||||
get element(): ElementRef { return <ElementRef>unimplemented(); }
|
abstract get element(): ElementRef;
|
||||||
|
|
||||||
get injector(): Injector { return <Injector>unimplemented(); }
|
abstract get injector(): Injector;
|
||||||
|
|
||||||
get parentInjector(): Injector { return <Injector>unimplemented(); }
|
abstract get parentInjector(): Injector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroys all Views in this container.
|
* Destroys all Views in this container.
|
||||||
|
@ -61,7 +60,7 @@ export abstract class ViewContainerRef {
|
||||||
/**
|
/**
|
||||||
* Returns the number of Views currently attached to this container.
|
* Returns the number of Views currently attached to this container.
|
||||||
*/
|
*/
|
||||||
get length(): number { return <number>unimplemented(); };
|
abstract get length(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates an Embedded View based on the {@link TemplateRef `templateRef`} and inserts it
|
* Instantiates an Embedded View based on the {@link TemplateRef `templateRef`} and inserts it
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
import {AnimationQueue} from '../animation/animation_queue';
|
import {AnimationQueue} from '../animation/animation_queue';
|
||||||
import {ChangeDetectorRef} from '../change_detection/change_detector_ref';
|
import {ChangeDetectorRef} from '../change_detection/change_detector_ref';
|
||||||
import {ChangeDetectorStatus} from '../change_detection/constants';
|
import {ChangeDetectorStatus} from '../change_detection/constants';
|
||||||
import {unimplemented} from '../facade/errors';
|
|
||||||
import {AppView} from './view';
|
import {AppView} from './view';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +20,7 @@ export abstract class ViewRef extends ChangeDetectorRef {
|
||||||
*/
|
*/
|
||||||
abstract destroy(): void;
|
abstract destroy(): void;
|
||||||
|
|
||||||
get destroyed(): boolean { return <boolean>unimplemented(); }
|
abstract get destroyed(): boolean;
|
||||||
|
|
||||||
abstract onDestroy(callback: Function): any /** TODO #9100 */;
|
abstract onDestroy(callback: Function): any /** TODO #9100 */;
|
||||||
}
|
}
|
||||||
|
@ -81,9 +80,9 @@ export abstract class ViewRef extends ChangeDetectorRef {
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
export abstract class EmbeddedViewRef<C> extends ViewRef {
|
export abstract class EmbeddedViewRef<C> extends ViewRef {
|
||||||
get context(): C { return unimplemented(); }
|
abstract get context(): C;
|
||||||
|
|
||||||
get rootNodes(): any[] { return <any[]>unimplemented(); };
|
abstract get rootNodes(): any[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ViewRef_<C> implements EmbeddedViewRef<C>, ChangeDetectorRef {
|
export class ViewRef_<C> implements EmbeddedViewRef<C>, ChangeDetectorRef {
|
||||||
|
|
|
@ -10,7 +10,6 @@ import {AnimationKeyframe} from '../../src/animation/animation_keyframe';
|
||||||
import {AnimationPlayer} from '../../src/animation/animation_player';
|
import {AnimationPlayer} from '../../src/animation/animation_player';
|
||||||
import {AnimationStyles} from '../../src/animation/animation_styles';
|
import {AnimationStyles} from '../../src/animation/animation_styles';
|
||||||
import {Injector} from '../di/injector';
|
import {Injector} from '../di/injector';
|
||||||
import {unimplemented} from '../facade/errors';
|
|
||||||
import {ViewEncapsulation} from '../metadata/view';
|
import {ViewEncapsulation} from '../metadata/view';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,12 +24,12 @@ export class RenderComponentType {
|
||||||
}
|
}
|
||||||
|
|
||||||
export abstract class RenderDebugInfo {
|
export abstract class RenderDebugInfo {
|
||||||
get injector(): Injector { return unimplemented(); }
|
abstract get injector(): Injector;
|
||||||
get component(): any { return unimplemented(); }
|
abstract get component(): any;
|
||||||
get providerTokens(): any[] { return unimplemented(); }
|
abstract get providerTokens(): any[];
|
||||||
get references(): {[key: string]: any} { return unimplemented(); }
|
abstract get references(): {[key: string]: any};
|
||||||
get context(): any { return unimplemented(); }
|
abstract get context(): any;
|
||||||
get source(): string { return unimplemented(); }
|
abstract get source(): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DirectRenderer {
|
export interface DirectRenderer {
|
||||||
|
|
Loading…
Reference in New Issue