refactor: replace any[] with Provider[] where possible

This commit is contained in:
Igor Minar
2016-08-24 13:39:44 -07:00
committed by Victor Berchet
parent eb7d8c702c
commit ea2e5521e8
34 changed files with 79 additions and 83 deletions
+5 -4
View File
@@ -14,7 +14,7 @@ import {ApplicationInitStatus} from './application_init';
import {APP_BOOTSTRAP_LISTENER, PLATFORM_INITIALIZER} from './application_tokens';
import {ChangeDetectorRef} from './change_detection/change_detector_ref';
import {Console} from './console';
import {Injectable, Injector, OpaqueToken, Optional, ReflectiveInjector} from './di';
import {Injectable, Injector, OpaqueToken, Optional, Provider, ReflectiveInjector} from './di';
import {CompilerFactory, CompilerOptions} from './linker/compiler';
import {ComponentFactory, ComponentRef} from './linker/component_factory';
import {ComponentFactoryResolver} from './linker/component_factory_resolver';
@@ -81,7 +81,7 @@ export function createPlatform(injector: Injector): PlatformRef {
*
* @experimental
*/
export type PlatformFactory = (extraProviders?: any[]) => PlatformRef;
export type PlatformFactory = (extraProviders?: Provider[]) => PlatformRef;
/**
* Creates a factory for a platform
@@ -89,9 +89,10 @@ export type PlatformFactory = (extraProviders?: any[]) => PlatformRef;
* @experimental APIs related to application bootstrap are currently under review.
*/
export function createPlatformFactory(
parentPlaformFactory: PlatformFactory, name: string, providers: any[] = []): PlatformFactory {
parentPlaformFactory: PlatformFactory, name: string,
providers: Provider[] = []): PlatformFactory {
const marker = new OpaqueToken(`Platform: ${name}`);
return (extraProviders: any[] = []) => {
return (extraProviders: Provider[] = []) => {
if (!getPlatform()) {
if (parentPlaformFactory) {
parentPlaformFactory(
@@ -8,7 +8,7 @@
import {AnimationEntryMetadata} from '../animation/metadata';
import {ChangeDetectionStrategy} from '../change_detection/constants';
import {InjectableMetadata} from '../di/metadata';
import {InjectableMetadata, Provider} from '../di';
import {isPresent} from '../facade/lang';
import {Type} from '../type';
import {ViewEncapsulation} from './view';
@@ -668,8 +668,8 @@ export class DirectiveMetadata extends InjectableMetadata implements DirectiveMe
* }
* ```
*/
get providers(): any[] { return this._providers; }
private _providers: any[];
get providers(): Provider[] { return this._providers; }
private _providers: Provider[];
/**
* Defines the name that can be used in the template to assign this directive to a variable.
@@ -835,8 +835,8 @@ export class ComponentMetadata extends DirectiveMetadata implements ComponentMet
*
* ```
*/
get viewProviders(): any[] { return this._viewProviders; }
private _viewProviders: any[];
get viewProviders(): Provider[] { return this._viewProviders; }
private _viewProviders: Provider[];
/**
* The module id of the module that contains the component.
@@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {InjectableMetadata} from '../di/metadata';
import {InjectableMetadata, Provider} from '../di';
import {Type} from '../type';
/**
@@ -16,7 +16,7 @@ import {Type} from '../type';
*/
export interface ModuleWithProviders {
ngModule: Type<any>;
providers?: any[];
providers?: Provider[];
}
/**
@@ -50,7 +50,7 @@ export const NO_ERRORS_SCHEMA: SchemaMetadata = {
* @stable
*/
export interface NgModuleMetadataType {
providers?: any[];
providers?: Provider[];
declarations?: Array<Type<any>|any[]>;
imports?: Array<Type<any>|ModuleWithProviders|any[]>;
exports?: Array<Type<any>|any[]>;
@@ -93,8 +93,8 @@ export class NgModuleMetadata extends InjectableMetadata implements NgModuleMeta
* }
* ```
*/
get providers(): any[] { return this._providers; }
private _providers: any[];
get providers(): Provider[] { return this._providers; }
private _providers: Provider[];
/**
@@ -8,7 +8,7 @@
import {PlatformRef, PlatformRef_, createPlatformFactory} from './application_ref';
import {Console} from './console';
import {Provider} from './di';
import {ClassProvider, ExistingProvider, FactoryProvider, Provider, TypeProvider, ValueProvider} from './di';
import {Reflector, reflector} from './reflection/reflection';
import {ReflectorReader} from './reflection/reflector_reader';
import {TestabilityRegistry} from './testability/testability';