From ea2e5521e86bb187afb28212b8d795dece10a694 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 24 Aug 2016 13:39:44 -0700 Subject: [PATCH] refactor: replace any[] with Provider[] where possible --- modules/@angular/compiler/src/compiler.ts | 4 +--- modules/@angular/compiler/src/provider_analyzer.ts | 1 - .../compiler/testing/directive_resolver_mock.ts | 11 ++++++----- modules/@angular/compiler/testing/test_bindings.ts | 4 +++- modules/@angular/core/src/application_ref.ts | 9 +++++---- modules/@angular/core/src/metadata/directives.ts | 10 +++++----- modules/@angular/core/src/metadata/ng_module.ts | 10 +++++----- .../@angular/core/src/platform_core_providers.ts | 2 +- .../core/test/di/reflective_injector_spec.ts | 4 ++-- .../core/test/linker/ng_module_integration_spec.ts | 4 ++-- .../test/linker/regression_integration_spec.ts | 6 ++---- .../test/linker/view_injector_integration_spec.ts | 9 +++------ .../@angular/examples/core/ts/platform/platform.ts | 2 -- modules/@angular/platform-browser-dynamic/index.ts | 2 +- .../src/platform_providers.ts | 4 ++-- .../@angular/platform-browser-dynamic/testing.ts | 2 +- modules/@angular/platform-browser/src/browser.ts | 2 +- .../platform-browser/src/dom/debug/ng_probe.ts | 4 ++-- .../@angular/platform-browser/src/worker_app.ts | 5 +++-- .../@angular/platform-browser/src/worker_render.ts | 2 +- .../test/browser/bootstrap_spec.ts | 7 +++---- .../@angular/platform-browser/testing/browser.ts | 2 +- modules/@angular/platform-server/src/server.ts | 6 +++--- modules/@angular/platform-server/testing/server.ts | 3 ++- modules/@angular/router/src/router_module.ts | 4 ++-- modules/benchpress/src/runner.ts | 6 +++--- .../benchpress/test/metric/perflog_metric_spec.ts | 3 ++- tools/public_api_guard/core/index.d.ts | 14 +++++++------- .../platform-browser-dynamic/index.d.ts | 4 ++-- .../platform-browser-dynamic/testing.d.ts | 2 +- tools/public_api_guard/platform-browser/index.d.ts | 6 +++--- .../public_api_guard/platform-browser/testing.d.ts | 2 +- tools/public_api_guard/platform-server/index.d.ts | 4 ++-- .../public_api_guard/platform-server/testing.d.ts | 2 +- 34 files changed, 79 insertions(+), 83 deletions(-) diff --git a/modules/@angular/compiler/src/compiler.ts b/modules/@angular/compiler/src/compiler.ts index b2d842670a..28325e1279 100644 --- a/modules/@angular/compiler/src/compiler.ts +++ b/modules/@angular/compiler/src/compiler.ts @@ -6,7 +6,7 @@ * 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 {TEMPLATE_TRANSFORMS} from './template_parser/template_parser'; @@ -21,8 +21,6 @@ export {DirectiveResolver} from './directive_resolver'; export {PipeResolver} from './pipe_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 {HtmlParser} from './ml_parser/html_parser'; import {DirectiveNormalizer} from './directive_normalizer'; diff --git a/modules/@angular/compiler/src/provider_analyzer.ts b/modules/@angular/compiler/src/provider_analyzer.ts index 00f792a2f3..337749ee1f 100644 --- a/modules/@angular/compiler/src/provider_analyzer.ts +++ b/modules/@angular/compiler/src/provider_analyzer.ts @@ -277,7 +277,6 @@ export class ProviderElementContext { export class NgModuleProviderAnalyzer { private _transformedProviders = new CompileIdentifierMap(); private _seenProviders = new CompileIdentifierMap(); - private _unparsedProviders: any[] = []; private _allProviders: CompileIdentifierMap; private _errors: ProviderError[] = []; diff --git a/modules/@angular/compiler/testing/directive_resolver_mock.ts b/modules/@angular/compiler/testing/directive_resolver_mock.ts index ae888a6f29..1d8204a39a 100644 --- a/modules/@angular/compiler/testing/directive_resolver_mock.ts +++ b/modules/@angular/compiler/testing/directive_resolver_mock.ts @@ -6,7 +6,7 @@ * 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 {DirectiveResolver} from '../src/directive_resolver'; @@ -48,14 +48,15 @@ export class MockDirectiveResolver extends DirectiveResolver { let providers = metadata.providers; if (isPresent(providerOverrides)) { - const originalViewProviders: any[] = isPresent(metadata.providers) ? metadata.providers : []; + const originalViewProviders: Provider[] = + isPresent(metadata.providers) ? metadata.providers : []; providers = originalViewProviders.concat(providerOverrides); } if (metadata instanceof ComponentMetadata) { let viewProviders = metadata.viewProviders; if (isPresent(viewProviderOverrides)) { - const originalViewProviders: any[] = + const originalViewProviders: Provider[] = isPresent(metadata.viewProviders) ? metadata.viewProviders : []; viewProviders = originalViewProviders.concat(viewProviderOverrides); } @@ -121,12 +122,12 @@ export class MockDirectiveResolver extends DirectiveResolver { this._clearCacheFor(type); } - setProvidersOverride(type: Type, providers: any[]): void { + setProvidersOverride(type: Type, providers: Provider[]): void { this._providerOverrides.set(type, providers); this._clearCacheFor(type); } - setViewProvidersOverride(type: Type, viewProviders: any[]): void { + setViewProvidersOverride(type: Type, viewProviders: Provider[]): void { this._viewProviderOverrides.set(type, viewProviders); this._clearCacheFor(type); } diff --git a/modules/@angular/compiler/testing/test_bindings.ts b/modules/@angular/compiler/testing/test_bindings.ts index ab5ac643c3..f87fd5327b 100644 --- a/modules/@angular/compiler/testing/test_bindings.ts +++ b/modules/@angular/compiler/testing/test_bindings.ts @@ -10,11 +10,13 @@ import {ElementSchemaRegistry, ResourceLoader, UrlResolver} from '@angular/compi import {createUrlResolverWithoutPackagePrefix} from '@angular/compiler/src/url_resolver'; import {MockSchemaRegistry} from '@angular/compiler/testing'; 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 // internal test packages. // 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: ResourceLoader, useClass: MockResourceLoader}, {provide: UrlResolver, useFactory: createUrlResolverWithoutPackagePrefix} diff --git a/modules/@angular/core/src/application_ref.ts b/modules/@angular/core/src/application_ref.ts index 9e822d3ad1..cbe08171df 100644 --- a/modules/@angular/core/src/application_ref.ts +++ b/modules/@angular/core/src/application_ref.ts @@ -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( diff --git a/modules/@angular/core/src/metadata/directives.ts b/modules/@angular/core/src/metadata/directives.ts index 708eb8049a..9bba9fa383 100644 --- a/modules/@angular/core/src/metadata/directives.ts +++ b/modules/@angular/core/src/metadata/directives.ts @@ -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. diff --git a/modules/@angular/core/src/metadata/ng_module.ts b/modules/@angular/core/src/metadata/ng_module.ts index e1f55259b7..df2e7d7404 100644 --- a/modules/@angular/core/src/metadata/ng_module.ts +++ b/modules/@angular/core/src/metadata/ng_module.ts @@ -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; - providers?: any[]; + providers?: Provider[]; } /** @@ -50,7 +50,7 @@ export const NO_ERRORS_SCHEMA: SchemaMetadata = { * @stable */ export interface NgModuleMetadataType { - providers?: any[]; + providers?: Provider[]; declarations?: Array|any[]>; imports?: Array|ModuleWithProviders|any[]>; exports?: Array|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[]; /** diff --git a/modules/@angular/core/src/platform_core_providers.ts b/modules/@angular/core/src/platform_core_providers.ts index 9818270bfd..5b977201c7 100644 --- a/modules/@angular/core/src/platform_core_providers.ts +++ b/modules/@angular/core/src/platform_core_providers.ts @@ -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'; diff --git a/modules/@angular/core/test/di/reflective_injector_spec.ts b/modules/@angular/core/test/di/reflective_injector_spec.ts index 8f60096815..4ac45b3289 100644 --- a/modules/@angular/core/test/di/reflective_injector_spec.ts +++ b/modules/@angular/core/test/di/reflective_injector_spec.ts @@ -6,7 +6,7 @@ * 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 {ReflectiveInjectorDynamicStrategy, ReflectiveInjectorInlineStrategy, ReflectiveInjector_, ReflectiveProtoInjector} from '@angular/core/src/di/reflective_injector'; import {ResolvedReflectiveProvider_} from '@angular/core/src/di/reflective_provider'; @@ -93,7 +93,7 @@ export function main() { strategyClass: ReflectiveInjectorDynamicStrategy }].forEach((context) => { function createInjector( - providers: any[], parent: ReflectiveInjector = null): ReflectiveInjector_ { + providers: Provider[], parent: ReflectiveInjector = null): ReflectiveInjector_ { var resolvedProviders = ReflectiveInjector.resolve(providers.concat(context['providers'])); if (isPresent(parent)) { return parent.createChildFromResolved(resolvedProviders); diff --git a/modules/@angular/core/test/linker/ng_module_integration_spec.ts b/modules/@angular/core/test/linker/ng_module_integration_spec.ts index 42c28af8be..6757c767c6 100644 --- a/modules/@angular/core/test/linker/ng_module_integration_spec.ts +++ b/modules/@angular/core/test/linker/ng_module_integration_spec.ts @@ -6,7 +6,7 @@ * 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 {ComponentFixture, TestBed, inject} from '@angular/core/testing'; import {expect} from '@angular/platform-browser/testing/matchers'; @@ -567,7 +567,7 @@ function declareTests({useJit}: {useJit: boolean}) { let moduleType: any = null; - function createInjector(providers: any[], parent: Injector = null): Injector { + function createInjector(providers: Provider[], parent: Injector = null): Injector { @NgModule({providers: providers}) class SomeModule { } diff --git a/modules/@angular/core/test/linker/regression_integration_spec.ts b/modules/@angular/core/test/linker/regression_integration_spec.ts index 93dc0f9a6f..4705daee80 100644 --- a/modules/@angular/core/test/linker/regression_integration_spec.ts +++ b/modules/@angular/core/test/linker/regression_integration_spec.ts @@ -6,9 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgClass, NgIf} from '@angular/common'; -import {Component, Injector, OpaqueToken, Pipe, PipeTransform, forwardRef} from '@angular/core'; -import {ViewMetadata} from '@angular/core/src/metadata/view'; +import {Component, Injector, OpaqueToken, Pipe, PipeTransform, Provider} from '@angular/core'; import {TestBed} from '@angular/core/testing'; import {beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; import {expect} from '@angular/platform-browser/testing/matchers'; @@ -84,7 +82,7 @@ function declareTests({useJit}: {useJit: boolean}) { }); describe('providers', () => { - function createInjector(providers: any[]): Injector { + function createInjector(providers: Provider[]): Injector { TestBed.overrideComponent(MyComp1, {add: {providers}}); return TestBed.createComponent(MyComp1).componentInstance.injector; } diff --git a/modules/@angular/core/test/linker/view_injector_integration_spec.ts b/modules/@angular/core/test/linker/view_injector_integration_spec.ts index b75b6c0050..e9a43ef5d3 100644 --- a/modules/@angular/core/test/linker/view_injector_integration_spec.ts +++ b/modules/@angular/core/test/linker/view_injector_integration_spec.ts @@ -6,15 +6,12 @@ * 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, Self, SkipSelfMetadata, TemplateRef, Type, ViewContainerRef, forwardRef} from '@angular/core'; -import {ViewMetadata} from '@angular/core/src/metadata/view'; +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 {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 {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {expect} from '@angular/platform-browser/testing/matchers'; -import {isBlank} from '../../src/facade/lang'; @Directive({selector: '[simpleDirective]'}) class SimpleDirective { @@ -194,7 +191,7 @@ class TestComp { export function main() { function createComponentFixture( - template: string, providers: any[] = null, comp: Type = null): ComponentFixture { + template: string, providers: Provider[] = null, comp: Type = null): ComponentFixture { if (!comp) { comp = TestComp; } @@ -206,7 +203,7 @@ export function main() { } function createComponent( - template: string, providers: any[] = null, comp: Type = null): DebugElement { + template: string, providers: Provider[] = null, comp: Type = null): DebugElement { const fixture = createComponentFixture(template, providers, comp); fixture.detectChanges(); return fixture.debugElement; diff --git a/modules/@angular/examples/core/ts/platform/platform.ts b/modules/@angular/examples/core/ts/platform/platform.ts index 842bbbef87..6dacc098c2 100644 --- a/modules/@angular/examples/core/ts/platform/platform.ts +++ b/modules/@angular/examples/core/ts/platform/platform.ts @@ -10,8 +10,6 @@ import {Component, ReflectiveInjector, createPlatformFactory} from '@angular/cor import {BrowserModule} from '@angular/platform-browser'; import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; -var appProviders: any[] = []; - // #docregion longform @Component({selector: 'my-app', template: 'Hello World'}) class MyApp { diff --git a/modules/@angular/platform-browser-dynamic/index.ts b/modules/@angular/platform-browser-dynamic/index.ts index 17bcab73fe..0283ba4832 100644 --- a/modules/@angular/platform-browser-dynamic/index.ts +++ b/modules/@angular/platform-browser-dynamic/index.ts @@ -7,7 +7,7 @@ */ 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 {INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from './src/platform_providers'; diff --git a/modules/@angular/platform-browser-dynamic/src/platform_providers.ts b/modules/@angular/platform-browser-dynamic/src/platform_providers.ts index b4a73e6122..48a91af357 100644 --- a/modules/@angular/platform-browser-dynamic/src/platform_providers.ts +++ b/modules/@angular/platform-browser-dynamic/src/platform_providers.ts @@ -7,13 +7,13 @@ */ 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 {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, { provide: COMPILER_OPTIONS, diff --git a/modules/@angular/platform-browser-dynamic/testing.ts b/modules/@angular/platform-browser-dynamic/testing.ts index 0db3a658e2..0a38b0e0e8 100644 --- a/modules/@angular/platform-browser-dynamic/testing.ts +++ b/modules/@angular/platform-browser-dynamic/testing.ts @@ -7,7 +7,7 @@ */ 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 {BrowserTestingModule} from '@angular/platform-browser/testing'; diff --git a/modules/@angular/platform-browser/src/browser.ts b/modules/@angular/platform-browser/src/browser.ts index 8713bfc34c..f97592af61 100644 --- a/modules/@angular/platform-browser/src/browser.ts +++ b/modules/@angular/platform-browser/src/browser.ts @@ -7,7 +7,7 @@ */ 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 {AnimationDriver} from '../src/dom/animation_driver'; diff --git a/modules/@angular/platform-browser/src/dom/debug/ng_probe.ts b/modules/@angular/platform-browser/src/dom/debug/ng_probe.ts index 949a47412e..5076f714e8 100644 --- a/modules/@angular/platform-browser/src/dom/debug/ng_probe.ts +++ b/modules/@angular/platform-browser/src/dom/debug/ng_probe.ts @@ -6,7 +6,7 @@ * 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 {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`). */ -export const ELEMENT_PROBE_PROVIDERS: any[] = [{ +export const ELEMENT_PROBE_PROVIDERS: Provider[] = [{ provide: RootRenderer, useFactory: _createConditionalRootRenderer, deps: [DomRootRenderer, [NgProbeToken, new Optional()]] diff --git a/modules/@angular/platform-browser/src/worker_app.ts b/modules/@angular/platform-browser/src/worker_app.ts index 97aac6e8c6..e8291f309a 100644 --- a/modules/@angular/platform-browser/src/worker_app.ts +++ b/modules/@angular/platform-browser/src/worker_app.ts @@ -7,10 +7,10 @@ */ 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 {isBlank, print} from './facade/lang'; +import {print} from './facade/lang'; import {ON_WEB_WORKER} from './web_workers/shared/api'; import {ClientMessageBrokerFactory, ClientMessageBrokerFactory_} from './web_workers/shared/client_message_broker'; 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 {WorkerDomAdapter} from './web_workers/worker/worker_adapter'; + /** * Logger for web workers. * diff --git a/modules/@angular/platform-browser/src/worker_render.ts b/modules/@angular/platform-browser/src/worker_render.ts index 925154f402..a4cb724bf3 100644 --- a/modules/@angular/platform-browser/src/worker_render.ts +++ b/modules/@angular/platform-browser/src/worker_render.ts @@ -6,7 +6,7 @@ * 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'; diff --git a/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts b/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts index 7bdcdd8d0e..ca6b994d32 100644 --- a/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts +++ b/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts @@ -6,8 +6,7 @@ * 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, createPlatformFactory} from '@angular/core'; +import {APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, Directive, ExceptionHandler, Inject, Input, NgModule, OnDestroy, PLATFORM_INITIALIZER, Pipe, Provider, createPlatformFactory} from '@angular/core'; import {ApplicationRef, destroyPlatform} from '@angular/core/src/application_ref'; import {Console} from '@angular/core/src/console'; import {ComponentRef} from '@angular/core/src/linker/component_factory'; @@ -113,7 +112,7 @@ class DummyConsole implements Console { class TestModule {} -function bootstrap(cmpType: any, providers: any = []): Promise { +function bootstrap(cmpType: any, providers: Provider[] = []): Promise { @NgModule({ imports: [BrowserModule], declarations: [cmpType], @@ -128,7 +127,7 @@ function bootstrap(cmpType: any, providers: any = []): Promise { export function main() { 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', () => { let compilerConsole: DummyConsole; diff --git a/modules/@angular/platform-browser/testing/browser.ts b/modules/@angular/platform-browser/testing/browser.ts index 59c607280a..16c5e44d75 100644 --- a/modules/@angular/platform-browser/testing/browser.ts +++ b/modules/@angular/platform-browser/testing/browser.ts @@ -6,7 +6,7 @@ * 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 {BrowserDomAdapter} from '../src/browser/browser_adapter'; diff --git a/modules/@angular/platform-server/src/server.ts b/modules/@angular/platform-server/src/server.ts index be858acf9e..01330458bb 100644 --- a/modules/@angular/platform-server/src/server.ts +++ b/modules/@angular/platform-server/src/server.ts @@ -7,11 +7,11 @@ */ import {PlatformLocation} from '@angular/common'; -import {analyzeAppProvidersForDeprecatedConfiguration, platformCoreDynamic} from '@angular/compiler'; -import {ApplicationRef, ComponentRef, NgModule, PLATFORM_INITIALIZER, PlatformRef, Type, createPlatformFactory, platformCore} from '@angular/core'; +import {platformCoreDynamic} from '@angular/compiler'; +import {ClassProvider, ExistingProvider, FactoryProvider, NgModule, PLATFORM_INITIALIZER, PlatformRef, TypeProvider, ValueProvider, createPlatformFactory, platformCore} from '@angular/core'; import {BrowserModule} from '@angular/platform-browser'; -import {Console, ReflectionCapabilities, reflector, wtfInit} from '../core_private'; +import {wtfInit} from '../core_private'; import {Parse5DomAdapter} from './parse5_adapter'; diff --git a/modules/@angular/platform-server/testing/server.ts b/modules/@angular/platform-server/testing/server.ts index a1c94604c5..0275497bf4 100644 --- a/modules/@angular/platform-server/testing/server.ts +++ b/modules/@angular/platform-server/testing/server.ts @@ -7,7 +7,8 @@ */ 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 {INTERNAL_SERVER_PLATFORM_PROVIDERS} from '../src/server'; diff --git a/modules/@angular/router/src/router_module.ts b/modules/@angular/router/src/router_module.ts index 19d182c31d..c95a0daf4b 100644 --- a/modules/@angular/router/src/router_module.ts +++ b/modules/@angular/router/src/router_module.ts @@ -7,7 +7,7 @@ */ 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 {RouterLink, RouterLinkWithHref} from './directives/router_link'; @@ -43,7 +43,7 @@ const hashLocationStrategy = { useClass: HashLocationStrategy }; -export const ROUTER_PROVIDERS: any[] = [ +export const ROUTER_PROVIDERS: Provider[] = [ Location, {provide: UrlSerializer, useClass: DefaultUrlSerializer}, { provide: Router, useFactory: setupRouter, diff --git a/modules/benchpress/src/runner.ts b/modules/benchpress/src/runner.ts index 3b88472135..753956b219 100644 --- a/modules/benchpress/src/runner.ts +++ b/modules/benchpress/src/runner.ts @@ -6,7 +6,7 @@ * 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 {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. */ export class Runner { - private _defaultProviders: any[]; - constructor(defaultProviders: any[] = null) { + private _defaultProviders: Provider[]; + constructor(defaultProviders: Provider[] = null) { if (isBlank(defaultProviders)) { defaultProviders = []; } diff --git a/modules/benchpress/test/metric/perflog_metric_spec.ts b/modules/benchpress/test/metric/perflog_metric_spec.ts index f5a487c710..477ee9dcf9 100644 --- a/modules/benchpress/test/metric/perflog_metric_spec.ts +++ b/modules/benchpress/test/metric/perflog_metric_spec.ts @@ -6,6 +6,7 @@ * 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 {StringMapWrapper} from '@angular/facade/src/collection'; import {isBlank, isPresent} from '@angular/facade/src/lang'; @@ -34,7 +35,7 @@ export function main() { if (isBlank(microMetrics)) { microMetrics = StringMapWrapper.create(); } - var providers: any[] = [ + var providers: Provider[] = [ Options.DEFAULT_PROVIDERS, PerflogMetric.PROVIDERS, {provide: Options.MICRO_METRICS, useValue: microMetrics}, { provide: PerflogMetric.SET_TIMEOUT, diff --git a/tools/public_api_guard/core/index.d.ts b/tools/public_api_guard/core/index.d.ts index 3b4665802e..d62bec97f3 100644 --- a/tools/public_api_guard/core/index.d.ts +++ b/tools/public_api_guard/core/index.d.ts @@ -294,7 +294,7 @@ export declare class ComponentMetadata extends DirectiveMetadata implements Comp styles: string[]; template: 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); } @@ -384,7 +384,7 @@ export interface ContentChildrenMetadataFactory { export declare function createPlatform(injector: Injector): PlatformRef; /** @experimental */ -export declare function createPlatformFactory(parentPlaformFactory: PlatformFactory, name: string, providers?: any[]): PlatformFactory; +export declare function createPlatformFactory(parentPlaformFactory: PlatformFactory, name: string, providers?: Provider[]): PlatformFactory; /** @stable */ export declare const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata; @@ -475,7 +475,7 @@ export declare class DirectiveMetadata extends InjectableMetadata implements Dir }; inputs: string[]; outputs: string[]; - providers: any[]; + providers: Provider[]; queries: { [key: string]: any; }; @@ -765,7 +765,7 @@ export declare class ModuleWithComponentFactories { /** @stable */ export interface ModuleWithProviders { ngModule: Type; - providers?: any[]; + providers?: Provider[]; } /** @stable */ @@ -796,7 +796,7 @@ export declare class NgModuleMetadata extends InjectableMetadata implements NgMo entryComponents: Array | any[]>; exports: Array | any[]>; imports: Array | ModuleWithProviders | any[]>; - providers: any[]; + providers: Provider[]; schemas: Array; constructor(options?: NgModuleMetadataType); } @@ -814,7 +814,7 @@ export interface NgModuleMetadataType { entryComponents?: Array | any[]>; exports?: Array | any[]>; imports?: Array | ModuleWithProviders | any[]>; - providers?: any[]; + providers?: Provider[]; schemas?: Array; } @@ -955,7 +955,7 @@ export interface PipeTransform { export declare const PLATFORM_INITIALIZER: any; /** @experimental */ -export declare const platformCore: (extraProviders?: any[]) => PlatformRef; +export declare const platformCore: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef; /** @stable */ export declare abstract class PlatformRef { diff --git a/tools/public_api_guard/platform-browser-dynamic/index.d.ts b/tools/public_api_guard/platform-browser-dynamic/index.d.ts index 6eeeb490ae..c611777000 100644 --- a/tools/public_api_guard/platform-browser-dynamic/index.d.ts +++ b/tools/public_api_guard/platform-browser-dynamic/index.d.ts @@ -2,10 +2,10 @@ export declare function bootstrapWorkerUi(workerScriptUri: string, customProviders?: Provider[]): Promise; /** @stable */ -export declare const platformBrowserDynamic: (extraProviders?: any[]) => PlatformRef; +export declare const platformBrowserDynamic: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef; /** @experimental */ -export declare const platformWorkerAppDynamic: (extraProviders?: any[]) => PlatformRef; +export declare const platformWorkerAppDynamic: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef; /** @experimental */ export declare const RESOURCE_CACHE_PROVIDER: Provider[]; diff --git a/tools/public_api_guard/platform-browser-dynamic/testing.d.ts b/tools/public_api_guard/platform-browser-dynamic/testing.d.ts index 43aa1d48b6..95cb78e2d1 100644 --- a/tools/public_api_guard/platform-browser-dynamic/testing.d.ts +++ b/tools/public_api_guard/platform-browser-dynamic/testing.d.ts @@ -3,4 +3,4 @@ export declare class BrowserDynamicTestingModule { } /** @stable */ -export declare const platformBrowserDynamicTesting: (extraProviders?: any[]) => PlatformRef; +export declare const platformBrowserDynamicTesting: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef; diff --git a/tools/public_api_guard/platform-browser/index.d.ts b/tools/public_api_guard/platform-browser/index.d.ts index 7ffe9fb1f3..75f863de5f 100644 --- a/tools/public_api_guard/platform-browser/index.d.ts +++ b/tools/public_api_guard/platform-browser/index.d.ts @@ -118,13 +118,13 @@ export declare class NgProbeToken { } /** @stable */ -export declare const platformBrowser: (extraProviders?: any[]) => PlatformRef; +export declare const platformBrowser: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef; /** @experimental */ -export declare const platformWorkerApp: (extraProviders?: any[]) => PlatformRef; +export declare const platformWorkerApp: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef; /** @experimental */ -export declare const platformWorkerUi: (extraProviders?: any[]) => PlatformRef; +export declare const platformWorkerUi: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef; /** @experimental */ export declare const PRIMITIVE: Type; diff --git a/tools/public_api_guard/platform-browser/testing.d.ts b/tools/public_api_guard/platform-browser/testing.d.ts index 7f7cf2b7ac..31f920accb 100644 --- a/tools/public_api_guard/platform-browser/testing.d.ts +++ b/tools/public_api_guard/platform-browser/testing.d.ts @@ -3,4 +3,4 @@ export declare class BrowserTestingModule { } /** @stable */ -export declare const platformBrowserTesting: (extraProviders?: any[]) => PlatformRef; +export declare const platformBrowserTesting: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef; diff --git a/tools/public_api_guard/platform-server/index.d.ts b/tools/public_api_guard/platform-server/index.d.ts index 124f89a4b5..30dd3a2fbd 100644 --- a/tools/public_api_guard/platform-server/index.d.ts +++ b/tools/public_api_guard/platform-server/index.d.ts @@ -1,8 +1,8 @@ /** @experimental */ -export declare const platformDynamicServer: (extraProviders?: any[]) => PlatformRef; +export declare const platformDynamicServer: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef; /** @experimental */ -export declare const platformServer: (extraProviders?: any[]) => PlatformRef; +export declare const platformServer: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef; /** @experimental */ export declare class ServerModule { diff --git a/tools/public_api_guard/platform-server/testing.d.ts b/tools/public_api_guard/platform-server/testing.d.ts index da4c2fcf08..8c9ba33c54 100644 --- a/tools/public_api_guard/platform-server/testing.d.ts +++ b/tools/public_api_guard/platform-server/testing.d.ts @@ -1,5 +1,5 @@ /** @experimental */ -export declare const platformServerTesting: (extraProviders?: any[]) => PlatformRef; +export declare const platformServerTesting: (extraProviders?: (TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[])[]) => PlatformRef; /** @experimental */ export declare class ServerTestingModule {