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

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {COMPILER_OPTIONS, Compiler, CompilerFactory, CompilerOptions, Component, Inject, Injectable, OptionalMetadata, PLATFORM_INITIALIZER, PlatformRef, Provider, ReflectiveInjector, TRANSLATIONS, TRANSLATIONS_FORMAT, Type, ViewEncapsulation, createPlatformFactory, isDevMode, platformCore} from '@angular/core'; import {COMPILER_OPTIONS, ClassProvider, Compiler, CompilerFactory, CompilerOptions, Component, ExistingProvider, FactoryProvider, Inject, Injectable, OptionalMetadata, PLATFORM_INITIALIZER, PlatformRef, Provider, ReflectiveInjector, TRANSLATIONS, TRANSLATIONS_FORMAT, Type, TypeProvider, ValueProvider, ViewEncapsulation, createPlatformFactory, isDevMode, platformCore} from '@angular/core';
export * from './template_parser/template_ast'; export * from './template_parser/template_ast';
export {TEMPLATE_TRANSFORMS} from './template_parser/template_parser'; export {TEMPLATE_TRANSFORMS} from './template_parser/template_parser';
@ -21,8 +21,6 @@ export {DirectiveResolver} from './directive_resolver';
export {PipeResolver} from './pipe_resolver'; export {PipeResolver} from './pipe_resolver';
export {NgModuleResolver} from './ng_module_resolver'; export {NgModuleResolver} from './ng_module_resolver';
import {stringify} from './facade/lang';
import {ListWrapper} from './facade/collection';
import {TemplateParser} from './template_parser/template_parser'; import {TemplateParser} from './template_parser/template_parser';
import {HtmlParser} from './ml_parser/html_parser'; import {HtmlParser} from './ml_parser/html_parser';
import {DirectiveNormalizer} from './directive_normalizer'; import {DirectiveNormalizer} from './directive_normalizer';

View File

@ -277,7 +277,6 @@ export class ProviderElementContext {
export class NgModuleProviderAnalyzer { export class NgModuleProviderAnalyzer {
private _transformedProviders = new CompileIdentifierMap<CompileTokenMetadata, ProviderAst>(); private _transformedProviders = new CompileIdentifierMap<CompileTokenMetadata, ProviderAst>();
private _seenProviders = new CompileIdentifierMap<CompileTokenMetadata, boolean>(); private _seenProviders = new CompileIdentifierMap<CompileTokenMetadata, boolean>();
private _unparsedProviders: any[] = [];
private _allProviders: CompileIdentifierMap<CompileTokenMetadata, ProviderAst>; private _allProviders: CompileIdentifierMap<CompileTokenMetadata, ProviderAst>;
private _errors: ProviderError[] = []; private _errors: ProviderError[] = [];

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {AnimationEntryMetadata, Compiler, ComponentMetadata, DirectiveMetadata, Injectable, Injector, Type, resolveForwardRef} from '@angular/core'; import {AnimationEntryMetadata, Compiler, ComponentMetadata, DirectiveMetadata, Injectable, Injector, Provider, Type, resolveForwardRef} from '@angular/core';
import {ViewMetadata} from '../core_private'; import {ViewMetadata} from '../core_private';
import {DirectiveResolver} from '../src/directive_resolver'; import {DirectiveResolver} from '../src/directive_resolver';
@ -48,14 +48,15 @@ export class MockDirectiveResolver extends DirectiveResolver {
let providers = metadata.providers; let providers = metadata.providers;
if (isPresent(providerOverrides)) { if (isPresent(providerOverrides)) {
const originalViewProviders: any[] = isPresent(metadata.providers) ? metadata.providers : []; const originalViewProviders: Provider[] =
isPresent(metadata.providers) ? metadata.providers : [];
providers = originalViewProviders.concat(providerOverrides); providers = originalViewProviders.concat(providerOverrides);
} }
if (metadata instanceof ComponentMetadata) { if (metadata instanceof ComponentMetadata) {
let viewProviders = metadata.viewProviders; let viewProviders = metadata.viewProviders;
if (isPresent(viewProviderOverrides)) { if (isPresent(viewProviderOverrides)) {
const originalViewProviders: any[] = const originalViewProviders: Provider[] =
isPresent(metadata.viewProviders) ? metadata.viewProviders : []; isPresent(metadata.viewProviders) ? metadata.viewProviders : [];
viewProviders = originalViewProviders.concat(viewProviderOverrides); viewProviders = originalViewProviders.concat(viewProviderOverrides);
} }
@ -121,12 +122,12 @@ export class MockDirectiveResolver extends DirectiveResolver {
this._clearCacheFor(type); this._clearCacheFor(type);
} }
setProvidersOverride(type: Type<any>, providers: any[]): void { setProvidersOverride(type: Type<any>, providers: Provider[]): void {
this._providerOverrides.set(type, providers); this._providerOverrides.set(type, providers);
this._clearCacheFor(type); this._clearCacheFor(type);
} }
setViewProvidersOverride(type: Type<any>, viewProviders: any[]): void { setViewProvidersOverride(type: Type<any>, viewProviders: Provider[]): void {
this._viewProviderOverrides.set(type, viewProviders); this._viewProviderOverrides.set(type, viewProviders);
this._clearCacheFor(type); this._clearCacheFor(type);
} }

View File

@ -10,11 +10,13 @@ import {ElementSchemaRegistry, ResourceLoader, UrlResolver} from '@angular/compi
import {createUrlResolverWithoutPackagePrefix} from '@angular/compiler/src/url_resolver'; import {createUrlResolverWithoutPackagePrefix} from '@angular/compiler/src/url_resolver';
import {MockSchemaRegistry} from '@angular/compiler/testing'; import {MockSchemaRegistry} from '@angular/compiler/testing';
import {MockResourceLoader} from '@angular/compiler/testing/resource_loader_mock'; import {MockResourceLoader} from '@angular/compiler/testing/resource_loader_mock';
import {Provider} from '@angular/core';
// This provider is put here just so that we can access it from multiple // This provider is put here just so that we can access it from multiple
// internal test packages. // internal test packages.
// TODO: get rid of it or move to a separate @angular/internal_testing package // TODO: get rid of it or move to a separate @angular/internal_testing package
export var TEST_COMPILER_PROVIDERS: any[] = [ export var TEST_COMPILER_PROVIDERS: Provider[] = [
{provide: ElementSchemaRegistry, useValue: new MockSchemaRegistry({}, {})}, {provide: ElementSchemaRegistry, useValue: new MockSchemaRegistry({}, {})},
{provide: ResourceLoader, useClass: MockResourceLoader}, {provide: ResourceLoader, useClass: MockResourceLoader},
{provide: UrlResolver, useFactory: createUrlResolverWithoutPackagePrefix} {provide: UrlResolver, useFactory: createUrlResolverWithoutPackagePrefix}

View File

@ -14,7 +14,7 @@ import {ApplicationInitStatus} from './application_init';
import {APP_BOOTSTRAP_LISTENER, PLATFORM_INITIALIZER} from './application_tokens'; import {APP_BOOTSTRAP_LISTENER, PLATFORM_INITIALIZER} from './application_tokens';
import {ChangeDetectorRef} from './change_detection/change_detector_ref'; import {ChangeDetectorRef} from './change_detection/change_detector_ref';
import {Console} from './console'; 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 {CompilerFactory, CompilerOptions} from './linker/compiler';
import {ComponentFactory, ComponentRef} from './linker/component_factory'; import {ComponentFactory, ComponentRef} from './linker/component_factory';
import {ComponentFactoryResolver} from './linker/component_factory_resolver'; import {ComponentFactoryResolver} from './linker/component_factory_resolver';
@ -81,7 +81,7 @@ export function createPlatform(injector: Injector): PlatformRef {
* *
* @experimental * @experimental
*/ */
export type PlatformFactory = (extraProviders?: any[]) => PlatformRef; export type PlatformFactory = (extraProviders?: Provider[]) => PlatformRef;
/** /**
* Creates a factory for a platform * 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. * @experimental APIs related to application bootstrap are currently under review.
*/ */
export function createPlatformFactory( export function createPlatformFactory(
parentPlaformFactory: PlatformFactory, name: string, providers: any[] = []): PlatformFactory { parentPlaformFactory: PlatformFactory, name: string,
providers: Provider[] = []): PlatformFactory {
const marker = new OpaqueToken(`Platform: ${name}`); const marker = new OpaqueToken(`Platform: ${name}`);
return (extraProviders: any[] = []) => { return (extraProviders: Provider[] = []) => {
if (!getPlatform()) { if (!getPlatform()) {
if (parentPlaformFactory) { if (parentPlaformFactory) {
parentPlaformFactory( parentPlaformFactory(

View File

@ -8,7 +8,7 @@
import {AnimationEntryMetadata} from '../animation/metadata'; import {AnimationEntryMetadata} from '../animation/metadata';
import {ChangeDetectionStrategy} from '../change_detection/constants'; import {ChangeDetectionStrategy} from '../change_detection/constants';
import {InjectableMetadata} from '../di/metadata'; import {InjectableMetadata, Provider} from '../di';
import {isPresent} from '../facade/lang'; import {isPresent} from '../facade/lang';
import {Type} from '../type'; import {Type} from '../type';
import {ViewEncapsulation} from './view'; import {ViewEncapsulation} from './view';
@ -668,8 +668,8 @@ export class DirectiveMetadata extends InjectableMetadata implements DirectiveMe
* } * }
* ``` * ```
*/ */
get providers(): any[] { return this._providers; } get providers(): Provider[] { return this._providers; }
private _providers: any[]; private _providers: Provider[];
/** /**
* Defines the name that can be used in the template to assign this directive to a variable. * 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; } get viewProviders(): Provider[] { return this._viewProviders; }
private _viewProviders: any[]; private _viewProviders: Provider[];
/** /**
* The module id of the module that contains the component. * The module id of the module that contains the component.

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {InjectableMetadata} from '../di/metadata'; import {InjectableMetadata, Provider} from '../di';
import {Type} from '../type'; import {Type} from '../type';
/** /**
@ -16,7 +16,7 @@ import {Type} from '../type';
*/ */
export interface ModuleWithProviders { export interface ModuleWithProviders {
ngModule: Type<any>; ngModule: Type<any>;
providers?: any[]; providers?: Provider[];
} }
/** /**
@ -50,7 +50,7 @@ export const NO_ERRORS_SCHEMA: SchemaMetadata = {
* @stable * @stable
*/ */
export interface NgModuleMetadataType { export interface NgModuleMetadataType {
providers?: any[]; providers?: Provider[];
declarations?: Array<Type<any>|any[]>; declarations?: Array<Type<any>|any[]>;
imports?: Array<Type<any>|ModuleWithProviders|any[]>; imports?: Array<Type<any>|ModuleWithProviders|any[]>;
exports?: Array<Type<any>|any[]>; exports?: Array<Type<any>|any[]>;
@ -93,8 +93,8 @@ export class NgModuleMetadata extends InjectableMetadata implements NgModuleMeta
* } * }
* ``` * ```
*/ */
get providers(): any[] { return this._providers; } get providers(): Provider[] { return this._providers; }
private _providers: any[]; private _providers: Provider[];
/** /**

View File

@ -8,7 +8,7 @@
import {PlatformRef, PlatformRef_, createPlatformFactory} from './application_ref'; import {PlatformRef, PlatformRef_, createPlatformFactory} from './application_ref';
import {Console} from './console'; import {Console} from './console';
import {Provider} from './di'; import {ClassProvider, ExistingProvider, FactoryProvider, Provider, TypeProvider, ValueProvider} from './di';
import {Reflector, reflector} from './reflection/reflection'; import {Reflector, reflector} from './reflection/reflection';
import {ReflectorReader} from './reflection/reflector_reader'; import {ReflectorReader} from './reflection/reflector_reader';
import {TestabilityRegistry} from './testability/testability'; import {TestabilityRegistry} from './testability/testability';

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Inject, InjectMetadata, Injectable, Injector, Optional, ReflectiveInjector, ReflectiveKey, SelfMetadata, forwardRef} from '@angular/core'; import {Inject, InjectMetadata, Injectable, Injector, Optional, Provider, ReflectiveInjector, ReflectiveKey, SelfMetadata, forwardRef} from '@angular/core';
import {DependencyMetadata} from '@angular/core/src/di/metadata'; import {DependencyMetadata} from '@angular/core/src/di/metadata';
import {ReflectiveInjectorDynamicStrategy, ReflectiveInjectorInlineStrategy, ReflectiveInjector_, ReflectiveProtoInjector} from '@angular/core/src/di/reflective_injector'; import {ReflectiveInjectorDynamicStrategy, ReflectiveInjectorInlineStrategy, ReflectiveInjector_, ReflectiveProtoInjector} from '@angular/core/src/di/reflective_injector';
import {ResolvedReflectiveProvider_} from '@angular/core/src/di/reflective_provider'; import {ResolvedReflectiveProvider_} from '@angular/core/src/di/reflective_provider';
@ -93,7 +93,7 @@ export function main() {
strategyClass: ReflectiveInjectorDynamicStrategy strategyClass: ReflectiveInjectorDynamicStrategy
}].forEach((context) => { }].forEach((context) => {
function createInjector( function createInjector(
providers: any[], parent: ReflectiveInjector = null): ReflectiveInjector_ { providers: Provider[], parent: ReflectiveInjector = null): ReflectiveInjector_ {
var resolvedProviders = ReflectiveInjector.resolve(providers.concat(context['providers'])); var resolvedProviders = ReflectiveInjector.resolve(providers.concat(context['providers']));
if (isPresent(parent)) { if (isPresent(parent)) {
return <ReflectiveInjector_>parent.createChildFromResolved(resolvedProviders); return <ReflectiveInjector_>parent.createChildFromResolved(resolvedProviders);

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {ANALYZE_FOR_ENTRY_COMPONENTS, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, ComponentFactoryResolver, Directive, HostBinding, Inject, Injectable, Injector, Input, NgModule, NgModuleRef, Optional, Pipe, SelfMetadata, Type, forwardRef} from '@angular/core'; import {ANALYZE_FOR_ENTRY_COMPONENTS, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, ComponentFactoryResolver, Directive, HostBinding, Inject, Injectable, Injector, Input, NgModule, NgModuleRef, Optional, Pipe, Provider, SelfMetadata, Type, forwardRef} from '@angular/core';
import {Console} from '@angular/core/src/console'; import {Console} from '@angular/core/src/console';
import {ComponentFixture, TestBed, inject} from '@angular/core/testing'; import {ComponentFixture, TestBed, inject} from '@angular/core/testing';
import {expect} from '@angular/platform-browser/testing/matchers'; import {expect} from '@angular/platform-browser/testing/matchers';
@ -567,7 +567,7 @@ function declareTests({useJit}: {useJit: boolean}) {
let moduleType: any = null; let moduleType: any = null;
function createInjector(providers: any[], parent: Injector = null): Injector { function createInjector(providers: Provider[], parent: Injector = null): Injector {
@NgModule({providers: providers}) @NgModule({providers: providers})
class SomeModule { class SomeModule {
} }

View File

@ -6,9 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {NgClass, NgIf} from '@angular/common'; import {Component, Injector, OpaqueToken, Pipe, PipeTransform, Provider} from '@angular/core';
import {Component, Injector, OpaqueToken, Pipe, PipeTransform, forwardRef} from '@angular/core';
import {ViewMetadata} from '@angular/core/src/metadata/view';
import {TestBed} from '@angular/core/testing'; import {TestBed} from '@angular/core/testing';
import {beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; import {beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {expect} from '@angular/platform-browser/testing/matchers'; import {expect} from '@angular/platform-browser/testing/matchers';
@ -84,7 +82,7 @@ function declareTests({useJit}: {useJit: boolean}) {
}); });
describe('providers', () => { describe('providers', () => {
function createInjector(providers: any[]): Injector { function createInjector(providers: Provider[]): Injector {
TestBed.overrideComponent(MyComp1, {add: {providers}}); TestBed.overrideComponent(MyComp1, {add: {providers}});
return TestBed.createComponent(MyComp1).componentInstance.injector; return TestBed.createComponent(MyComp1).componentInstance.injector;
} }

View File

@ -6,15 +6,12 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {NgFor, NgIf} from '@angular/common'; import {Attribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, DebugElement, Directive, ElementRef, Host, Inject, InjectMetadata, Input, Optional, Pipe, PipeTransform, Provider, Self, SkipSelfMetadata, TemplateRef, Type, ViewContainerRef, forwardRef} from '@angular/core';
import {Attribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, DebugElement, Directive, ElementRef, Host, Inject, InjectMetadata, Input, Optional, Pipe, PipeTransform, Self, SkipSelfMetadata, TemplateRef, Type, ViewContainerRef, forwardRef} from '@angular/core';
import {ViewMetadata} from '@angular/core/src/metadata/view';
import {ComponentFixture, TestBed, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing'; import {ComponentFixture, TestBed, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
import {beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; import {beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {expect} from '@angular/platform-browser/testing/matchers'; import {expect} from '@angular/platform-browser/testing/matchers';
import {isBlank} from '../../src/facade/lang';
@Directive({selector: '[simpleDirective]'}) @Directive({selector: '[simpleDirective]'})
class SimpleDirective { class SimpleDirective {
@ -194,7 +191,7 @@ class TestComp {
export function main() { export function main() {
function createComponentFixture<T>( function createComponentFixture<T>(
template: string, providers: any[] = null, comp: Type<T> = null): ComponentFixture<T> { template: string, providers: Provider[] = null, comp: Type<T> = null): ComponentFixture<T> {
if (!comp) { if (!comp) {
comp = <any>TestComp; comp = <any>TestComp;
} }
@ -206,7 +203,7 @@ export function main() {
} }
function createComponent( function createComponent(
template: string, providers: any[] = null, comp: Type<any> = null): DebugElement { template: string, providers: Provider[] = null, comp: Type<any> = null): DebugElement {
const fixture = createComponentFixture(template, providers, comp); const fixture = createComponentFixture(template, providers, comp);
fixture.detectChanges(); fixture.detectChanges();
return fixture.debugElement; return fixture.debugElement;

View File

@ -10,8 +10,6 @@ import {Component, ReflectiveInjector, createPlatformFactory} from '@angular/cor
import {BrowserModule} from '@angular/platform-browser'; import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
var appProviders: any[] = [];
// #docregion longform // #docregion longform
@Component({selector: 'my-app', template: 'Hello World'}) @Component({selector: 'my-app', template: 'Hello World'})
class MyApp { class MyApp {

View File

@ -7,7 +7,7 @@
*/ */
import {ResourceLoader, platformCoreDynamic} from '@angular/compiler'; import {ResourceLoader, platformCoreDynamic} from '@angular/compiler';
import {COMPILER_OPTIONS, PlatformRef, Provider, createPlatformFactory} from '@angular/core'; import {COMPILER_OPTIONS, ClassProvider, ExistingProvider, FactoryProvider, PlatformRef, Provider, TypeProvider, ValueProvider, createPlatformFactory} from '@angular/core';
import {WORKER_SCRIPT, platformWorkerUi} from '@angular/platform-browser'; import {WORKER_SCRIPT, platformWorkerUi} from '@angular/platform-browser';
import {INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from './src/platform_providers'; import {INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from './src/platform_providers';

View File

@ -7,13 +7,13 @@
*/ */
import {ResourceLoader} from '@angular/compiler'; import {ResourceLoader} from '@angular/compiler';
import {COMPILER_OPTIONS} from '@angular/core'; import {COMPILER_OPTIONS, Provider} from '@angular/core';
import {INTERNAL_BROWSER_PLATFORM_PROVIDERS} from '../platform_browser_private'; import {INTERNAL_BROWSER_PLATFORM_PROVIDERS} from '../platform_browser_private';
import {ResourceLoaderImpl} from './resource_loader/resource_loader_impl'; import {ResourceLoaderImpl} from './resource_loader/resource_loader_impl';
export const INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS: any[] = [ export const INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS: Provider[] = [
INTERNAL_BROWSER_PLATFORM_PROVIDERS, INTERNAL_BROWSER_PLATFORM_PROVIDERS,
{ {
provide: COMPILER_OPTIONS, provide: COMPILER_OPTIONS,

View File

@ -7,7 +7,7 @@
*/ */
import {platformCoreDynamicTesting} from '@angular/compiler/testing'; import {platformCoreDynamicTesting} from '@angular/compiler/testing';
import {NgModule, PlatformRef, createPlatformFactory} from '@angular/core'; import {ClassProvider, ExistingProvider, FactoryProvider, NgModule, PlatformRef, TypeProvider, ValueProvider, createPlatformFactory} from '@angular/core';
import {TestComponentRenderer} from '@angular/core/testing'; import {TestComponentRenderer} from '@angular/core/testing';
import {BrowserTestingModule} from '@angular/platform-browser/testing'; import {BrowserTestingModule} from '@angular/platform-browser/testing';

View File

@ -7,7 +7,7 @@
*/ */
import {CommonModule, PlatformLocation} from '@angular/common'; import {CommonModule, PlatformLocation} from '@angular/common';
import {ApplicationModule, BaseException, ExceptionHandler, NgModule, Optional, PLATFORM_INITIALIZER, PlatformRef, Provider, RootRenderer, SanitizationService, SkipSelf, Testability, createPlatformFactory, platformCore} from '@angular/core'; import {ApplicationModule, BaseException, ClassProvider, ExceptionHandler, ExistingProvider, FactoryProvider, NgModule, Optional, PLATFORM_INITIALIZER, PlatformRef, Provider, RootRenderer, SanitizationService, SkipSelf, Testability, TypeProvider, ValueProvider, createPlatformFactory, platformCore} from '@angular/core';
import {wtfInit} from '../core_private'; import {wtfInit} from '../core_private';
import {AnimationDriver} from '../src/dom/animation_driver'; import {AnimationDriver} from '../src/dom/animation_driver';

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {ApplicationRef, DebugNode, NgZone, Optional, RootRenderer, getDebugNode, isDevMode} from '@angular/core'; import {ApplicationRef, DebugNode, NgZone, Optional, Provider, RootRenderer, getDebugNode, isDevMode} from '@angular/core';
import {DebugDomRootRenderer} from '../../../core_private'; import {DebugDomRootRenderer} from '../../../core_private';
import {StringMapWrapper} from '../../facade/collection'; import {StringMapWrapper} from '../../facade/collection';
@ -61,7 +61,7 @@ function _ngProbeTokensToMap(tokens: NgProbeToken[]): {[name: string]: any} {
/** /**
* Providers which support debugging Angular applications (e.g. via `ng.probe`). * Providers which support debugging Angular applications (e.g. via `ng.probe`).
*/ */
export const ELEMENT_PROBE_PROVIDERS: any[] = [{ export const ELEMENT_PROBE_PROVIDERS: Provider[] = [{
provide: RootRenderer, provide: RootRenderer,
useFactory: _createConditionalRootRenderer, useFactory: _createConditionalRootRenderer,
deps: [DomRootRenderer, [NgProbeToken, new Optional()]] deps: [DomRootRenderer, [NgProbeToken, new Optional()]]

View File

@ -7,10 +7,10 @@
*/ */
import {CommonModule} from '@angular/common'; import {CommonModule} from '@angular/common';
import {APP_INITIALIZER, ApplicationModule, ExceptionHandler, NgModule, NgZone, OpaqueToken, PlatformRef, ReflectiveInjector, RootRenderer, assertPlatform, createPlatform, createPlatformFactory, getPlatform, platformCore} from '@angular/core'; import {APP_INITIALIZER, ApplicationModule, ClassProvider, ExceptionHandler, ExistingProvider, FactoryProvider, NgModule, NgZone, PlatformRef, RootRenderer, TypeProvider, ValueProvider, createPlatformFactory, platformCore} from '@angular/core';
import {BROWSER_SANITIZATION_PROVIDERS} from './browser'; import {BROWSER_SANITIZATION_PROVIDERS} from './browser';
import {isBlank, print} from './facade/lang'; import {print} from './facade/lang';
import {ON_WEB_WORKER} from './web_workers/shared/api'; import {ON_WEB_WORKER} from './web_workers/shared/api';
import {ClientMessageBrokerFactory, ClientMessageBrokerFactory_} from './web_workers/shared/client_message_broker'; import {ClientMessageBrokerFactory, ClientMessageBrokerFactory_} from './web_workers/shared/client_message_broker';
import {MessageBus} from './web_workers/shared/message_bus'; import {MessageBus} from './web_workers/shared/message_bus';
@ -21,6 +21,7 @@ import {ServiceMessageBrokerFactory, ServiceMessageBrokerFactory_} from './web_w
import {WebWorkerRootRenderer} from './web_workers/worker/renderer'; import {WebWorkerRootRenderer} from './web_workers/worker/renderer';
import {WorkerDomAdapter} from './web_workers/worker/worker_adapter'; import {WorkerDomAdapter} from './web_workers/worker/worker_adapter';
/** /**
* Logger for web workers. * Logger for web workers.
* *

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {BaseException, ExceptionHandler, Injectable, Injector, NgZone, OpaqueToken, PLATFORM_INITIALIZER, PlatformRef, Provider, RootRenderer, Testability, createPlatformFactory, isDevMode, platformCore} from '@angular/core'; import {BaseException, ClassProvider, ExceptionHandler, ExistingProvider, FactoryProvider, Injectable, Injector, NgZone, OpaqueToken, PLATFORM_INITIALIZER, PlatformRef, Provider, RootRenderer, Testability, TypeProvider, ValueProvider, createPlatformFactory, isDevMode, platformCore} from '@angular/core';
import {wtfInit} from '../core_private'; import {wtfInit} from '../core_private';

View File

@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {ResourceLoader} from '@angular/compiler'; import {APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, Directive, ExceptionHandler, Inject, Input, NgModule, OnDestroy, PLATFORM_INITIALIZER, Pipe, Provider, createPlatformFactory} from '@angular/core';
import {APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, Directive, ExceptionHandler, Inject, Input, NgModule, OnDestroy, PLATFORM_INITIALIZER, Pipe, createPlatformFactory} from '@angular/core';
import {ApplicationRef, destroyPlatform} from '@angular/core/src/application_ref'; import {ApplicationRef, destroyPlatform} from '@angular/core/src/application_ref';
import {Console} from '@angular/core/src/console'; import {Console} from '@angular/core/src/console';
import {ComponentRef} from '@angular/core/src/linker/component_factory'; import {ComponentRef} from '@angular/core/src/linker/component_factory';
@ -113,7 +112,7 @@ class DummyConsole implements Console {
class TestModule {} class TestModule {}
function bootstrap(cmpType: any, providers: any = []): Promise<any> { function bootstrap(cmpType: any, providers: Provider[] = []): Promise<any> {
@NgModule({ @NgModule({
imports: [BrowserModule], imports: [BrowserModule],
declarations: [cmpType], declarations: [cmpType],
@ -128,7 +127,7 @@ function bootstrap(cmpType: any, providers: any = []): Promise<any> {
export function main() { export function main() {
var fakeDoc: any /** TODO #9100 */, el: any /** TODO #9100 */, el2: any /** TODO #9100 */, var fakeDoc: any /** TODO #9100 */, el: any /** TODO #9100 */, el2: any /** TODO #9100 */,
testProviders: any /** TODO #9100 */, lightDom: any /** TODO #9100 */; testProviders: Provider[], lightDom: any /** TODO #9100 */;
describe('bootstrap factory method', () => { describe('bootstrap factory method', () => {
let compilerConsole: DummyConsole; let compilerConsole: DummyConsole;

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {APP_ID, NgModule, NgZone, PLATFORM_INITIALIZER, PlatformRef, Provider, createPlatformFactory, platformCore} from '@angular/core'; import {APP_ID, ClassProvider, ExistingProvider, FactoryProvider, NgModule, NgZone, PLATFORM_INITIALIZER, PlatformRef, Provider, TypeProvider, ValueProvider, createPlatformFactory, platformCore} from '@angular/core';
import {BrowserModule} from '../src/browser'; import {BrowserModule} from '../src/browser';
import {BrowserDomAdapter} from '../src/browser/browser_adapter'; import {BrowserDomAdapter} from '../src/browser/browser_adapter';

View File

@ -7,11 +7,11 @@
*/ */
import {PlatformLocation} from '@angular/common'; import {PlatformLocation} from '@angular/common';
import {analyzeAppProvidersForDeprecatedConfiguration, platformCoreDynamic} from '@angular/compiler'; import {platformCoreDynamic} from '@angular/compiler';
import {ApplicationRef, ComponentRef, NgModule, PLATFORM_INITIALIZER, PlatformRef, Type, createPlatformFactory, platformCore} from '@angular/core'; import {ClassProvider, ExistingProvider, FactoryProvider, NgModule, PLATFORM_INITIALIZER, PlatformRef, TypeProvider, ValueProvider, createPlatformFactory, platformCore} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser'; import {BrowserModule} from '@angular/platform-browser';
import {Console, ReflectionCapabilities, reflector, wtfInit} from '../core_private'; import {wtfInit} from '../core_private';
import {Parse5DomAdapter} from './parse5_adapter'; import {Parse5DomAdapter} from './parse5_adapter';

View File

@ -7,7 +7,8 @@
*/ */
import {platformCoreDynamicTesting} from '@angular/compiler/testing'; import {platformCoreDynamicTesting} from '@angular/compiler/testing';
import {NgModule, PlatformRef, createPlatformFactory} from '@angular/core'; import {ClassProvider, ExistingProvider, FactoryProvider, NgModule, PlatformRef, TypeProvider, ValueProvider, createPlatformFactory} from '@angular/core';
import {BrowserDynamicTestingModule,} from '@angular/platform-browser-dynamic/testing'; import {BrowserDynamicTestingModule,} from '@angular/platform-browser-dynamic/testing';
import {INTERNAL_SERVER_PLATFORM_PROVIDERS} from '../src/server'; import {INTERNAL_SERVER_PLATFORM_PROVIDERS} from '../src/server';

View File

@ -7,7 +7,7 @@
*/ */
import {APP_BASE_HREF, HashLocationStrategy, Location, LocationStrategy, PathLocationStrategy, PlatformLocation} from '@angular/common'; import {APP_BASE_HREF, HashLocationStrategy, Location, LocationStrategy, PathLocationStrategy, PlatformLocation} from '@angular/common';
import {ANALYZE_FOR_ENTRY_COMPONENTS, APP_BOOTSTRAP_LISTENER, ApplicationRef, BaseException, Compiler, Inject, Injector, ModuleWithProviders, NgModule, NgModuleFactoryLoader, OpaqueToken, Optional, SkipSelf, SystemJsNgModuleLoader} from '@angular/core'; import {ANALYZE_FOR_ENTRY_COMPONENTS, APP_BOOTSTRAP_LISTENER, ApplicationRef, BaseException, Compiler, Inject, Injector, ModuleWithProviders, NgModule, NgModuleFactoryLoader, OpaqueToken, Optional, Provider, SkipSelf, SystemJsNgModuleLoader} from '@angular/core';
import {Route, Routes} from './config'; import {Route, Routes} from './config';
import {RouterLink, RouterLinkWithHref} from './directives/router_link'; import {RouterLink, RouterLinkWithHref} from './directives/router_link';
@ -43,7 +43,7 @@ const hashLocationStrategy = {
useClass: HashLocationStrategy useClass: HashLocationStrategy
}; };
export const ROUTER_PROVIDERS: any[] = [ export const ROUTER_PROVIDERS: Provider[] = [
Location, {provide: UrlSerializer, useClass: DefaultUrlSerializer}, { Location, {provide: UrlSerializer, useClass: DefaultUrlSerializer}, {
provide: Router, provide: Router,
useFactory: setupRouter, useFactory: setupRouter,

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {ReflectiveInjector} from '@angular/core'; import {Provider, ReflectiveInjector} from '@angular/core';
import {isBlank, isPresent} from '@angular/facade/src/lang'; import {isBlank, isPresent} from '@angular/facade/src/lang';
import {Options} from './common_options'; import {Options} from './common_options';
@ -34,8 +34,8 @@ import {IOsDriverExtension} from './webdriver/ios_driver_extension';
* It provides defaults, creates the injector and calls the sampler. * It provides defaults, creates the injector and calls the sampler.
*/ */
export class Runner { export class Runner {
private _defaultProviders: any[]; private _defaultProviders: Provider[];
constructor(defaultProviders: any[] = null) { constructor(defaultProviders: Provider[] = null) {
if (isBlank(defaultProviders)) { if (isBlank(defaultProviders)) {
defaultProviders = []; defaultProviders = [];
} }

View File

@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Provider} from '@angular/core';
import {AsyncTestCompleter, afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
import {StringMapWrapper} from '@angular/facade/src/collection'; import {StringMapWrapper} from '@angular/facade/src/collection';
import {isBlank, isPresent} from '@angular/facade/src/lang'; import {isBlank, isPresent} from '@angular/facade/src/lang';
@ -34,7 +35,7 @@ export function main() {
if (isBlank(microMetrics)) { if (isBlank(microMetrics)) {
microMetrics = StringMapWrapper.create(); microMetrics = StringMapWrapper.create();
} }
var providers: any[] = [ var providers: Provider[] = [
Options.DEFAULT_PROVIDERS, PerflogMetric.PROVIDERS, Options.DEFAULT_PROVIDERS, PerflogMetric.PROVIDERS,
{provide: Options.MICRO_METRICS, useValue: microMetrics}, { {provide: Options.MICRO_METRICS, useValue: microMetrics}, {
provide: PerflogMetric.SET_TIMEOUT, provide: PerflogMetric.SET_TIMEOUT,

View File

@ -294,7 +294,7 @@ export declare class ComponentMetadata extends DirectiveMetadata implements Comp
styles: string[]; styles: string[];
template: string; template: string;
templateUrl: string; templateUrl: string;
viewProviders: any[]; viewProviders: Provider[];
constructor({selector, inputs, outputs, host, exportAs, moduleId, providers, viewProviders, changeDetection, queries, templateUrl, template, styleUrls, styles, animations, encapsulation, interpolation, entryComponents}?: ComponentMetadataType); constructor({selector, inputs, outputs, host, exportAs, moduleId, providers, viewProviders, changeDetection, queries, templateUrl, template, styleUrls, styles, animations, encapsulation, interpolation, entryComponents}?: ComponentMetadataType);
} }
@ -384,7 +384,7 @@ export interface ContentChildrenMetadataFactory {
export declare function createPlatform(injector: Injector): PlatformRef; export declare function createPlatform(injector: Injector): PlatformRef;
/** @experimental */ /** @experimental */
export declare function createPlatformFactory(parentPlaformFactory: PlatformFactory, name: string, providers?: any[]): PlatformFactory; export declare function createPlatformFactory(parentPlaformFactory: PlatformFactory, name: string, providers?: Provider[]): PlatformFactory;
/** @stable */ /** @stable */
export declare const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata; export declare const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata;
@ -475,7 +475,7 @@ export declare class DirectiveMetadata extends InjectableMetadata implements Dir
}; };
inputs: string[]; inputs: string[];
outputs: string[]; outputs: string[];
providers: any[]; providers: Provider[];
queries: { queries: {
[key: string]: any; [key: string]: any;
}; };
@ -765,7 +765,7 @@ export declare class ModuleWithComponentFactories<T> {
/** @stable */ /** @stable */
export interface ModuleWithProviders { export interface ModuleWithProviders {
ngModule: Type<any>; ngModule: Type<any>;
providers?: any[]; providers?: Provider[];
} }
/** @stable */ /** @stable */
@ -796,7 +796,7 @@ export declare class NgModuleMetadata extends InjectableMetadata implements NgMo
entryComponents: Array<Type<any> | any[]>; entryComponents: Array<Type<any> | any[]>;
exports: Array<Type<any> | any[]>; exports: Array<Type<any> | any[]>;
imports: Array<Type<any> | ModuleWithProviders | any[]>; imports: Array<Type<any> | ModuleWithProviders | any[]>;
providers: any[]; providers: Provider[];
schemas: Array<SchemaMetadata | any[]>; schemas: Array<SchemaMetadata | any[]>;
constructor(options?: NgModuleMetadataType); constructor(options?: NgModuleMetadataType);
} }
@ -814,7 +814,7 @@ export interface NgModuleMetadataType {
entryComponents?: Array<Type<any> | any[]>; entryComponents?: Array<Type<any> | any[]>;
exports?: Array<Type<any> | any[]>; exports?: Array<Type<any> | any[]>;
imports?: Array<Type<any> | ModuleWithProviders | any[]>; imports?: Array<Type<any> | ModuleWithProviders | any[]>;
providers?: any[]; providers?: Provider[];
schemas?: Array<SchemaMetadata | any[]>; schemas?: Array<SchemaMetadata | any[]>;
} }
@ -955,7 +955,7 @@ export interface PipeTransform {
export declare const PLATFORM_INITIALIZER: any; export declare const PLATFORM_INITIALIZER: any;
/** @experimental */ /** @experimental */
export declare const platformCore: (extraProviders?: any[]) => PlatformRef; export declare const platformCore: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef;
/** @stable */ /** @stable */
export declare abstract class PlatformRef { export declare abstract class PlatformRef {

View File

@ -2,10 +2,10 @@
export declare function bootstrapWorkerUi(workerScriptUri: string, customProviders?: Provider[]): Promise<PlatformRef>; export declare function bootstrapWorkerUi(workerScriptUri: string, customProviders?: Provider[]): Promise<PlatformRef>;
/** @stable */ /** @stable */
export declare const platformBrowserDynamic: (extraProviders?: any[]) => PlatformRef; export declare const platformBrowserDynamic: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef;
/** @experimental */ /** @experimental */
export declare const platformWorkerAppDynamic: (extraProviders?: any[]) => PlatformRef; export declare const platformWorkerAppDynamic: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef;
/** @experimental */ /** @experimental */
export declare const RESOURCE_CACHE_PROVIDER: Provider[]; export declare const RESOURCE_CACHE_PROVIDER: Provider[];

View File

@ -3,4 +3,4 @@ export declare class BrowserDynamicTestingModule {
} }
/** @stable */ /** @stable */
export declare const platformBrowserDynamicTesting: (extraProviders?: any[]) => PlatformRef; export declare const platformBrowserDynamicTesting: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef;

View File

@ -118,13 +118,13 @@ export declare class NgProbeToken {
} }
/** @stable */ /** @stable */
export declare const platformBrowser: (extraProviders?: any[]) => PlatformRef; export declare const platformBrowser: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef;
/** @experimental */ /** @experimental */
export declare const platformWorkerApp: (extraProviders?: any[]) => PlatformRef; export declare const platformWorkerApp: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef;
/** @experimental */ /** @experimental */
export declare const platformWorkerUi: (extraProviders?: any[]) => PlatformRef; export declare const platformWorkerUi: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef;
/** @experimental */ /** @experimental */
export declare const PRIMITIVE: Type<any>; export declare const PRIMITIVE: Type<any>;

View File

@ -3,4 +3,4 @@ export declare class BrowserTestingModule {
} }
/** @stable */ /** @stable */
export declare const platformBrowserTesting: (extraProviders?: any[]) => PlatformRef; export declare const platformBrowserTesting: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef;

View File

@ -1,8 +1,8 @@
/** @experimental */ /** @experimental */
export declare const platformDynamicServer: (extraProviders?: any[]) => PlatformRef; export declare const platformDynamicServer: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef;
/** @experimental */ /** @experimental */
export declare const platformServer: (extraProviders?: any[]) => PlatformRef; export declare const platformServer: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef;
/** @experimental */ /** @experimental */
export declare class ServerModule { export declare class ServerModule {

View File

@ -1,5 +1,5 @@
/** @experimental */ /** @experimental */
export declare const platformServerTesting: (extraProviders?: any[]) => PlatformRef; export declare const platformServerTesting: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef;
/** @experimental */ /** @experimental */
export declare class ServerTestingModule { export declare class ServerTestingModule {