refactor(Type): merge Type and ConcreType<?> into Type<?> (#10616)
Closes #9729 BREAKING CHANGE: `Type` is now `Type<T>` which means that in most cases you have to use `Type<any>` in place of `Type`. We don't expect that any user applications use the `Type` type.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '@angular/core';
|
||||
import {Provider} from '@angular/core';
|
||||
|
||||
import {CORE_DIRECTIVES} from './directives';
|
||||
|
||||
@@ -55,4 +55,4 @@ import {CORE_DIRECTIVES} from './directives';
|
||||
*
|
||||
* @experimental Contains forms which are experimental.
|
||||
*/
|
||||
export const COMMON_DIRECTIVES: Type[][] = [CORE_DIRECTIVES];
|
||||
export const COMMON_DIRECTIVES: any[] = CORE_DIRECTIVES;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../facade/lang';
|
||||
import {Type} from '@angular/core';
|
||||
|
||||
import {NgClass} from './ng_class';
|
||||
import {NgFor} from './ng_for';
|
||||
@@ -58,7 +58,7 @@ import {NgTemplateOutlet} from './ng_template_outlet';
|
||||
*
|
||||
* @stable
|
||||
*/
|
||||
export const CORE_DIRECTIVES: Type[] = [
|
||||
export const CORE_DIRECTIVES: Type<any>[] = [
|
||||
NgClass,
|
||||
NgFor,
|
||||
NgIf,
|
||||
|
||||
@@ -57,7 +57,7 @@ export {NG_ASYNC_VALIDATORS, NG_VALIDATORS, Validators} from './forms-deprecated
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
export const FORM_PROVIDERS: Type[] = [FormBuilder, RadioControlRegistry];
|
||||
export const FORM_PROVIDERS: Type<any>[] = [FormBuilder, RadioControlRegistry];
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,7 +58,7 @@ export {MaxLengthValidator, MinLengthValidator, PatternValidator, RequiredValida
|
||||
* ```
|
||||
* @experimental
|
||||
*/
|
||||
export const FORM_DIRECTIVES: Type[] = [
|
||||
export const FORM_DIRECTIVES: Type<any>[] = [
|
||||
NgControlName,
|
||||
NgControlGroup,
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {BaseException} from '@angular/core';
|
||||
import {Type, stringify} from '../facade/lang';
|
||||
import {BaseException, Type} from '@angular/core';
|
||||
import {stringify} from '../facade/lang';
|
||||
|
||||
export class InvalidPipeArgumentException extends BaseException {
|
||||
constructor(type: Type, value: Object) {
|
||||
constructor(type: Type<any>, value: Object) {
|
||||
super(`Invalid argument '${value}' for pipe '${stringify(type)}'`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
import {Pipe, PipeTransform, Type} from '@angular/core';
|
||||
|
||||
import {NumberFormatStyle, NumberFormatter} from '../facade/intl';
|
||||
import {NumberWrapper, Type, isBlank, isNumber, isPresent, isString} from '../facade/lang';
|
||||
import {NumberWrapper, isBlank, isNumber, isPresent, isString} from '../facade/lang';
|
||||
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
|
||||
@@ -17,7 +17,7 @@ var defaultLocale: string = 'en-US';
|
||||
const _NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(\-(\d+))?)?$/;
|
||||
|
||||
function formatNumber(
|
||||
pipe: Type, value: number | string, style: NumberFormatStyle, digits: string,
|
||||
pipe: Type<any>, value: number | string, style: NumberFormatStyle, digits: string,
|
||||
currency: string = null, currencyAsSymbol: boolean = false): string {
|
||||
if (isBlank(value)) return null;
|
||||
// Convert strings to numbers
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ChangeDetectionStrategy, SchemaMetadata, ViewEncapsulation} from '@angular/core';
|
||||
import {ChangeDetectionStrategy, SchemaMetadata, Type, ViewEncapsulation} from '@angular/core';
|
||||
|
||||
import {LifecycleHooks, reflector} from '../core_private';
|
||||
|
||||
import {ListWrapper, StringMapWrapper} from './facade/collection';
|
||||
import {BaseException, unimplemented} from './facade/exceptions';
|
||||
import {Type, isBlank, isPresent, isStringMap, normalizeBlank, normalizeBool} from './facade/lang';
|
||||
|
||||
import {isBlank, isPresent, isStringMap, normalizeBlank, normalizeBool} from './facade/lang';
|
||||
import {CssSelector} from './selector';
|
||||
import {getUrlScheme} from './url_resolver';
|
||||
import {sanitizeIdentifier, splitAtColon} from './util';
|
||||
@@ -308,7 +308,7 @@ export class CompileTypeMetadata extends CompileIdentifierMetadata {
|
||||
lifecycleHooks: LifecycleHooks[];
|
||||
|
||||
constructor({runtime, name, moduleUrl, prefix, isHost, value, diDeps, lifecycleHooks}: {
|
||||
runtime?: Type,
|
||||
runtime?: Type<any>,
|
||||
name?: string,
|
||||
moduleUrl?: string,
|
||||
prefix?: string,
|
||||
@@ -685,8 +685,8 @@ export class CompileNgModuleMetadata implements CompileMetadataWithIdentifier {
|
||||
}
|
||||
|
||||
export class TransitiveCompileNgModuleMetadata {
|
||||
directivesSet = new Set<Type>();
|
||||
pipesSet = new Set<Type>();
|
||||
directivesSet = new Set<Type<any>>();
|
||||
pipesSet = new Set<Type<any>>();
|
||||
constructor(
|
||||
public modules: CompileNgModuleMetadata[], public providers: CompileProviderMetadata[],
|
||||
public entryComponents: CompileTypeMetadata[], public directives: CompileDirectiveMetadata[],
|
||||
|
||||
@@ -52,7 +52,7 @@ const _NO_XHR: XHR = {
|
||||
* A set of providers that provide `RuntimeCompiler` and its dependencies to use for
|
||||
* template compilation.
|
||||
*/
|
||||
export const COMPILER_PROVIDERS: Array<any|Type|{[k: string]: any}|any[]> = [
|
||||
export const COMPILER_PROVIDERS: Array<any|Type<any>|{[k: string]: any}|any[]> = [
|
||||
{provide: Reflector, useValue: reflector},
|
||||
{provide: ReflectorReader, useExisting: Reflector},
|
||||
{provide: XHR, useValue: _NO_XHR},
|
||||
@@ -79,8 +79,11 @@ export const COMPILER_PROVIDERS: Array<any|Type|{[k: string]: any}|any[]> = [
|
||||
];
|
||||
|
||||
|
||||
export function analyzeAppProvidersForDeprecatedConfiguration(appProviders: any[] = []):
|
||||
{compilerOptions: CompilerOptions, moduleDeclarations: Type[], deprecationMessages: string[]} {
|
||||
export function analyzeAppProvidersForDeprecatedConfiguration(appProviders: any[] = []): {
|
||||
compilerOptions: CompilerOptions,
|
||||
moduleDeclarations: Type<any>[],
|
||||
deprecationMessages: string[]
|
||||
} {
|
||||
let platformDirectives: any[] = [];
|
||||
let platformPipes: any[] = [];
|
||||
|
||||
|
||||
@@ -6,12 +6,11 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {BaseException, ComponentMetadata, DirectiveMetadata, HostBindingMetadata, HostListenerMetadata, Injectable, InputMetadata, OutputMetadata, QueryMetadata, resolveForwardRef} from '@angular/core';
|
||||
|
||||
import {ComponentMetadata, DirectiveMetadata, HostBindingMetadata, HostListenerMetadata, Injectable, InputMetadata, OutputMetadata, QueryMetadata, Type, resolveForwardRef} from '@angular/core';
|
||||
import {ReflectorReader, reflector} from '../core_private';
|
||||
|
||||
import {StringMapWrapper} from './facade/collection';
|
||||
import {Type, isPresent, stringify} from './facade/lang';
|
||||
import {BaseException} from './facade/exceptions';
|
||||
import {isPresent, stringify} from './facade/lang';
|
||||
import {splitAtColon} from './util';
|
||||
|
||||
function _isDirectiveMetadata(type: any): type is DirectiveMetadata {
|
||||
@@ -32,7 +31,7 @@ export class DirectiveResolver {
|
||||
/**
|
||||
* Return {@link DirectiveMetadata} for a given `Type`.
|
||||
*/
|
||||
resolve(type: Type, throwIfNotFound = true): DirectiveMetadata {
|
||||
resolve(type: Type<any>, throwIfNotFound = true): DirectiveMetadata {
|
||||
var typeMetadata = this._reflector.annotations(resolveForwardRef(type));
|
||||
if (isPresent(typeMetadata)) {
|
||||
var metadata = typeMetadata.find(_isDirectiveMetadata);
|
||||
@@ -49,7 +48,7 @@ export class DirectiveResolver {
|
||||
|
||||
private _mergeWithPropertyMetadata(
|
||||
dm: DirectiveMetadata, propertyMetadata: {[key: string]: any[]},
|
||||
directiveType: Type): DirectiveMetadata {
|
||||
directiveType: Type<any>): DirectiveMetadata {
|
||||
var inputs: string[] = [];
|
||||
var outputs: string[] = [];
|
||||
var host: {[key: string]: string} = {};
|
||||
@@ -90,7 +89,7 @@ export class DirectiveResolver {
|
||||
|
||||
private _merge(
|
||||
dm: DirectiveMetadata, inputs: string[], outputs: string[], host: {[key: string]: string},
|
||||
queries: {[key: string]: any}, directiveType: Type): DirectiveMetadata {
|
||||
queries: {[key: string]: any}, directiveType: Type<any>): DirectiveMetadata {
|
||||
let mergedInputs: string[];
|
||||
|
||||
if (isPresent(dm.inputs)) {
|
||||
|
||||
@@ -6,14 +6,13 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, DoCheck, OnChanges, OnDestroy, OnInit} from '@angular/core';
|
||||
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, DoCheck, OnChanges, OnDestroy, OnInit, Type} from '@angular/core';
|
||||
|
||||
import {LifecycleHooks, reflector} from '../core_private';
|
||||
|
||||
import {MapWrapper} from './facade/collection';
|
||||
import {Type} from './facade/lang';
|
||||
|
||||
const LIFECYCLE_INTERFACES: Map<any, Type> = MapWrapper.createFromPairs([
|
||||
const LIFECYCLE_INTERFACES: Map<any, Type<any>> = MapWrapper.createFromPairs([
|
||||
[LifecycleHooks.OnInit, OnInit],
|
||||
[LifecycleHooks.OnDestroy, OnDestroy],
|
||||
[LifecycleHooks.DoCheck, DoCheck],
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {AnimationAnimateMetadata, AnimationEntryMetadata, AnimationGroupMetadata, AnimationKeyframesSequenceMetadata, AnimationMetadata, AnimationStateDeclarationMetadata, AnimationStateMetadata, AnimationStateTransitionMetadata, AnimationStyleMetadata, AnimationWithStepsMetadata, AttributeMetadata, BaseException, ChangeDetectionStrategy, ComponentMetadata, HostMetadata, Inject, InjectMetadata, Injectable, ModuleWithProviders, NgModule, NgModuleMetadata, Optional, OptionalMetadata, Provider, QueryMetadata, SchemaMetadata, SelfMetadata, SkipSelfMetadata, ViewMetadata, ViewQueryMetadata, resolveForwardRef} from '@angular/core';
|
||||
import {AnimationAnimateMetadata, AnimationEntryMetadata, AnimationGroupMetadata, AnimationKeyframesSequenceMetadata, AnimationMetadata, AnimationStateDeclarationMetadata, AnimationStateMetadata, AnimationStateTransitionMetadata, AnimationStyleMetadata, AnimationWithStepsMetadata, AttributeMetadata, ChangeDetectionStrategy, ComponentMetadata, HostMetadata, InjectMetadata, Injectable, ModuleWithProviders, OptionalMetadata, Provider, QueryMetadata, SchemaMetadata, SelfMetadata, SkipSelfMetadata, Type, ViewQueryMetadata, resolveForwardRef} from '@angular/core';
|
||||
|
||||
import {Console, LIFECYCLE_HOOKS_VALUES, ReflectorReader, createProvider, isProviderLiteral, reflector} from '../core_private';
|
||||
import {StringMapWrapper} from '../src/facade/collection';
|
||||
@@ -15,7 +15,8 @@ import {assertArrayOfStrings, assertInterpolationSymbols} from './assertions';
|
||||
import * as cpl from './compile_metadata';
|
||||
import {CompilerConfig} from './config';
|
||||
import {DirectiveResolver} from './directive_resolver';
|
||||
import {Type, isArray, isBlank, isPresent, isString, stringify} from './facade/lang';
|
||||
import {BaseException} from './facade/exceptions';
|
||||
import {isArray, isBlank, isPresent, isString, stringify} from './facade/lang';
|
||||
import {Identifiers, identifierToken} from './identifiers';
|
||||
import {hasLifecycleHook} from './lifecycle_reflector';
|
||||
import {NgModuleResolver} from './ng_module_resolver';
|
||||
@@ -26,10 +27,10 @@ import {MODULE_SUFFIX, ValueTransformer, sanitizeIdentifier, visitValue} from '.
|
||||
|
||||
@Injectable()
|
||||
export class CompileMetadataResolver {
|
||||
private _directiveCache = new Map<Type, cpl.CompileDirectiveMetadata>();
|
||||
private _pipeCache = new Map<Type, cpl.CompilePipeMetadata>();
|
||||
private _ngModuleCache = new Map<Type, cpl.CompileNgModuleMetadata>();
|
||||
private _ngModuleOfTypes = new Map<Type, Type>();
|
||||
private _directiveCache = new Map<Type<any>, cpl.CompileDirectiveMetadata>();
|
||||
private _pipeCache = new Map<Type<any>, cpl.CompilePipeMetadata>();
|
||||
private _ngModuleCache = new Map<Type<any>, cpl.CompileNgModuleMetadata>();
|
||||
private _ngModuleOfTypes = new Map<Type<any>, Type<any>>();
|
||||
private _anonymousTypes = new Map<Object, number>();
|
||||
private _anonymousTypeIndex = 0;
|
||||
|
||||
@@ -53,7 +54,7 @@ export class CompileMetadataResolver {
|
||||
return sanitizeIdentifier(identifier);
|
||||
}
|
||||
|
||||
clearCacheFor(type: Type) {
|
||||
clearCacheFor(type: Type<any>) {
|
||||
this._directiveCache.delete(type);
|
||||
this._pipeCache.delete(type);
|
||||
this._ngModuleOfTypes.delete(type);
|
||||
@@ -110,7 +111,8 @@ export class CompileMetadataResolver {
|
||||
return null;
|
||||
}
|
||||
|
||||
getDirectiveMetadata(directiveType: Type, throwIfNotFound = true): cpl.CompileDirectiveMetadata {
|
||||
getDirectiveMetadata(directiveType: Type<any>, throwIfNotFound = true):
|
||||
cpl.CompileDirectiveMetadata {
|
||||
directiveType = resolveForwardRef(directiveType);
|
||||
var meta = this._directiveCache.get(directiveType);
|
||||
if (isBlank(meta)) {
|
||||
@@ -241,7 +243,7 @@ export class CompileMetadataResolver {
|
||||
|
||||
if (meta.imports) {
|
||||
flattenArray(meta.imports).forEach((importedType) => {
|
||||
let importedModuleType: Type;
|
||||
let importedModuleType: Type<any>;
|
||||
if (isValidType(importedType)) {
|
||||
importedModuleType = importedType;
|
||||
} else if (importedType && importedType.ngModule) {
|
||||
@@ -352,7 +354,7 @@ export class CompileMetadataResolver {
|
||||
return compileMeta;
|
||||
}
|
||||
|
||||
addComponentToModule(moduleType: Type, compType: Type) {
|
||||
addComponentToModule(moduleType: Type<any>, compType: Type<any>) {
|
||||
const moduleMeta = this.getNgModuleMetadata(moduleType);
|
||||
// Collect @Component.directives/pipes/entryComponents into our declared directives/pipes.
|
||||
const compMeta = this.getDirectiveMetadata(compType, false);
|
||||
@@ -395,7 +397,7 @@ export class CompileMetadataResolver {
|
||||
(dirMeta) => { this._getTransitiveViewDirectivesAndPipes(dirMeta, moduleMeta); });
|
||||
}
|
||||
|
||||
private _addTypeToModule(type: Type, moduleType: Type) {
|
||||
private _addTypeToModule(type: Type<any>, moduleType: Type<any>) {
|
||||
const oldModule = this._ngModuleOfTypes.get(type);
|
||||
if (oldModule && oldModule !== moduleType) {
|
||||
throw new BaseException(
|
||||
@@ -410,13 +412,13 @@ export class CompileMetadataResolver {
|
||||
if (!compMeta.isComponent) {
|
||||
return;
|
||||
}
|
||||
const addPipe = (pipeType: Type) => {
|
||||
const addPipe = (pipeType: Type<any>) => {
|
||||
const pipeMeta = this.getPipeMetadata(pipeType);
|
||||
this._addPipeToModule(
|
||||
pipeMeta, moduleMeta.type.runtime, moduleMeta.transitiveModule, moduleMeta.declaredPipes);
|
||||
};
|
||||
|
||||
const addDirective = (dirType: Type) => {
|
||||
const addDirective = (dirType: Type<any>) => {
|
||||
const dirMeta = this.getDirectiveMetadata(dirType);
|
||||
if (this._addDirectiveToModule(
|
||||
dirMeta, moduleMeta.type.runtime, moduleMeta.transitiveModule,
|
||||
@@ -484,7 +486,7 @@ export class CompileMetadataResolver {
|
||||
return false;
|
||||
}
|
||||
|
||||
getTypeMetadata(type: Type, moduleUrl: string, dependencies: any[] = null):
|
||||
getTypeMetadata(type: Type<any>, moduleUrl: string, dependencies: any[] = null):
|
||||
cpl.CompileTypeMetadata {
|
||||
type = resolveForwardRef(type);
|
||||
return new cpl.CompileTypeMetadata({
|
||||
@@ -507,7 +509,7 @@ export class CompileMetadataResolver {
|
||||
});
|
||||
}
|
||||
|
||||
getPipeMetadata(pipeType: Type, throwIfNotFound = true): cpl.CompilePipeMetadata {
|
||||
getPipeMetadata(pipeType: Type<any>, throwIfNotFound = true): cpl.CompilePipeMetadata {
|
||||
pipeType = resolveForwardRef(pipeType);
|
||||
var meta = this._pipeCache.get(pipeType);
|
||||
if (isBlank(meta)) {
|
||||
@@ -525,7 +527,7 @@ export class CompileMetadataResolver {
|
||||
return meta;
|
||||
}
|
||||
|
||||
getDependenciesMetadata(typeOrFunc: Type|Function, dependencies: any[]):
|
||||
getDependenciesMetadata(typeOrFunc: Type<any>|Function, dependencies: any[]):
|
||||
cpl.CompileDiDependencyMetadata[] {
|
||||
let hasUnknownDeps = false;
|
||||
let params = isPresent(dependencies) ? dependencies : this._reflector.parameters(typeOrFunc);
|
||||
@@ -694,7 +696,7 @@ export class CompileMetadataResolver {
|
||||
|
||||
getQueriesMetadata(
|
||||
queries: {[key: string]: QueryMetadata}, isViewQuery: boolean,
|
||||
directiveType: Type): cpl.CompileQueryMetadata[] {
|
||||
directiveType: Type<any>): cpl.CompileQueryMetadata[] {
|
||||
var res: cpl.CompileQueryMetadata[] = [];
|
||||
StringMapWrapper.forEach(queries, (query: QueryMetadata, propertyName: string) => {
|
||||
if (query.isViewQuery === isViewQuery) {
|
||||
@@ -704,7 +706,7 @@ export class CompileMetadataResolver {
|
||||
return res;
|
||||
}
|
||||
|
||||
getQueryMetadata(q: QueryMetadata, propertyName: string, typeOrFunc: Type|Function):
|
||||
getQueryMetadata(q: QueryMetadata, propertyName: string, typeOrFunc: Type<any>|Function):
|
||||
cpl.CompileQueryMetadata {
|
||||
var selectors: cpl.CompileTokenMetadata[];
|
||||
if (q.isVarBindingQuery) {
|
||||
@@ -729,7 +731,7 @@ export class CompileMetadataResolver {
|
||||
function getTransitiveModules(
|
||||
modules: cpl.CompileNgModuleMetadata[], includeImports: boolean,
|
||||
targetModules: cpl.CompileNgModuleMetadata[] = [],
|
||||
visitedModules = new Set<Type>()): cpl.CompileNgModuleMetadata[] {
|
||||
visitedModules = new Set<Type<any>>()): cpl.CompileNgModuleMetadata[] {
|
||||
modules.forEach((ngModule) => {
|
||||
if (!visitedModules.has(ngModule.type.runtime)) {
|
||||
visitedModules.add(ngModule.type.runtime);
|
||||
@@ -761,7 +763,7 @@ function flattenArray(tree: any[], out: Array<any> = []): Array<any> {
|
||||
}
|
||||
|
||||
function verifyNonBlankProviders(
|
||||
directiveType: Type, providersTree: any[], providersType: string): any[] {
|
||||
directiveType: Type<any>, providersTree: any[], providersType: string): any[] {
|
||||
var flat: any[] = [];
|
||||
var errMsg: string;
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {BaseException, Injectable, NgModuleMetadata} from '@angular/core';
|
||||
import {Injectable, NgModuleMetadata, Type} from '@angular/core';
|
||||
|
||||
import {ReflectorReader, reflector} from '../core_private';
|
||||
|
||||
import {Type, isPresent, stringify} from './facade/lang';
|
||||
import {BaseException} from '../src/facade/exceptions';
|
||||
import {isPresent, stringify} from './facade/lang';
|
||||
|
||||
function _isNgModuleMetadata(obj: any): obj is NgModuleMetadata {
|
||||
return obj instanceof NgModuleMetadata;
|
||||
@@ -23,7 +23,7 @@ function _isNgModuleMetadata(obj: any): obj is NgModuleMetadata {
|
||||
export class NgModuleResolver {
|
||||
constructor(private _reflector: ReflectorReader = reflector) {}
|
||||
|
||||
resolve(type: Type, throwIfNotFound = true): NgModuleMetadata {
|
||||
resolve(type: Type<any>, throwIfNotFound = true): NgModuleMetadata {
|
||||
const ngModuleMeta: NgModuleMetadata =
|
||||
this._reflector.annotations(type).find(_isNgModuleMetadata);
|
||||
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {BaseException, Injectable, PipeMetadata, resolveForwardRef} from '@angular/core';
|
||||
import {Injectable, PipeMetadata, Type, resolveForwardRef} from '@angular/core';
|
||||
|
||||
import {ReflectorReader, reflector} from '../core_private';
|
||||
|
||||
import {Type, isPresent, stringify} from './facade/lang';
|
||||
import {BaseException} from './facade/exceptions';
|
||||
import {isPresent, stringify} from './facade/lang';
|
||||
|
||||
function _isPipeMetadata(type: any): boolean {
|
||||
return type instanceof PipeMetadata;
|
||||
@@ -30,7 +31,7 @@ export class PipeResolver {
|
||||
/**
|
||||
* Return {@link PipeMetadata} for a given `Type`.
|
||||
*/
|
||||
resolve(type: Type, throwIfNotFound = true): PipeMetadata {
|
||||
resolve(type: Type<any>, throwIfNotFound = true): PipeMetadata {
|
||||
var metas = this._reflector.annotations(resolveForwardRef(type));
|
||||
if (isPresent(metas)) {
|
||||
var annotation = metas.find(_isPipeMetadata);
|
||||
|
||||
@@ -6,14 +6,15 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {BaseException, Compiler, ComponentFactory, ComponentResolver, ComponentStillLoadingError, Injectable, Injector, ModuleWithComponentFactories, NgModule, NgModuleFactory, NgModuleMetadata, OptionalMetadata, Provider, SchemaMetadata, SkipSelfMetadata} from '@angular/core';
|
||||
import {Compiler, ComponentFactory, ComponentResolver, ComponentStillLoadingError, Injectable, Injector, ModuleWithComponentFactories, NgModuleFactory, OptionalMetadata, Provider, SchemaMetadata, SkipSelfMetadata, Type} from '@angular/core';
|
||||
|
||||
import {Console} from '../core_private';
|
||||
|
||||
import {CompileDirectiveMetadata, CompileIdentifierMetadata, CompileNgModuleMetadata, CompilePipeMetadata, createHostComponentMeta} from './compile_metadata';
|
||||
import {CompilerConfig} from './config';
|
||||
import {DirectiveNormalizer} from './directive_normalizer';
|
||||
import {ConcreteType, Type, isBlank, isString, stringify} from './facade/lang';
|
||||
import {BaseException} from './facade/exceptions';
|
||||
import {isBlank, isString, stringify} from './facade/lang';
|
||||
import {CompileMetadataResolver} from './metadata_resolver';
|
||||
import {NgModuleCompiler} from './ng_module_compiler';
|
||||
import * as ir from './output/output_ast';
|
||||
@@ -37,9 +38,9 @@ import {ComponentFactoryDependency, ViewCompiler, ViewFactoryDependency} from '.
|
||||
*/
|
||||
@Injectable()
|
||||
export class RuntimeCompiler implements Compiler {
|
||||
private _compiledTemplateCache = new Map<Type, CompiledTemplate>();
|
||||
private _compiledHostTemplateCache = new Map<Type, CompiledTemplate>();
|
||||
private _compiledNgModuleCache = new Map<Type, NgModuleFactory<any>>();
|
||||
private _compiledTemplateCache = new Map<Type<any>, CompiledTemplate>();
|
||||
private _compiledHostTemplateCache = new Map<Type<any>, CompiledTemplate>();
|
||||
private _compiledNgModuleCache = new Map<Type<any>, NgModuleFactory<any>>();
|
||||
|
||||
constructor(
|
||||
private _injector: Injector, private _metadataResolver: CompileMetadataResolver,
|
||||
@@ -50,25 +51,24 @@ export class RuntimeCompiler implements Compiler {
|
||||
|
||||
get injector(): Injector { return this._injector; }
|
||||
|
||||
compileModuleSync<T>(moduleType: ConcreteType<T>): NgModuleFactory<T> {
|
||||
compileModuleSync<T>(moduleType: Type<T>): NgModuleFactory<T> {
|
||||
return this._compileModuleAndComponents(moduleType, true).syncResult;
|
||||
}
|
||||
|
||||
compileModuleAsync<T>(moduleType: ConcreteType<T>): Promise<NgModuleFactory<T>> {
|
||||
compileModuleAsync<T>(moduleType: Type<T>): Promise<NgModuleFactory<T>> {
|
||||
return this._compileModuleAndComponents(moduleType, false).asyncResult;
|
||||
}
|
||||
|
||||
compileModuleAndAllComponentsSync<T>(moduleType: ConcreteType<T>):
|
||||
ModuleWithComponentFactories<T> {
|
||||
compileModuleAndAllComponentsSync<T>(moduleType: Type<T>): ModuleWithComponentFactories<T> {
|
||||
return this._compileModuleAndAllComponents(moduleType, true).syncResult;
|
||||
}
|
||||
|
||||
compileModuleAndAllComponentsAsync<T>(moduleType: ConcreteType<T>):
|
||||
compileModuleAndAllComponentsAsync<T>(moduleType: Type<T>):
|
||||
Promise<ModuleWithComponentFactories<T>> {
|
||||
return this._compileModuleAndAllComponents(moduleType, false).asyncResult;
|
||||
}
|
||||
|
||||
compileComponentAsync<T>(compType: ConcreteType<T>, ngModule: ConcreteType<any> = null):
|
||||
compileComponentAsync<T>(compType: Type<T>, ngModule: Type<any> = null):
|
||||
Promise<ComponentFactory<T>> {
|
||||
if (!ngModule) {
|
||||
throw new BaseException(
|
||||
@@ -77,8 +77,7 @@ export class RuntimeCompiler implements Compiler {
|
||||
return this._compileComponentInModule(compType, false, ngModule).asyncResult;
|
||||
}
|
||||
|
||||
compileComponentSync<T>(compType: ConcreteType<T>, ngModule: ConcreteType<any> = null):
|
||||
ComponentFactory<T> {
|
||||
compileComponentSync<T>(compType: Type<T>, ngModule: Type<any> = null): ComponentFactory<T> {
|
||||
if (!ngModule) {
|
||||
throw new BaseException(
|
||||
`Calling compileComponentSync on the root compiler without a module is not allowed! (Compiling component ${stringify(compType)})`);
|
||||
@@ -86,14 +85,14 @@ export class RuntimeCompiler implements Compiler {
|
||||
return this._compileComponentInModule(compType, true, ngModule).syncResult;
|
||||
}
|
||||
|
||||
private _compileModuleAndComponents<T>(moduleType: ConcreteType<T>, isSync: boolean):
|
||||
private _compileModuleAndComponents<T>(moduleType: Type<T>, isSync: boolean):
|
||||
SyncAsyncResult<NgModuleFactory<T>> {
|
||||
const componentPromise = this._compileComponents(moduleType, isSync);
|
||||
const ngModuleFactory = this._compileModule(moduleType);
|
||||
return new SyncAsyncResult(ngModuleFactory, componentPromise.then(() => ngModuleFactory));
|
||||
}
|
||||
|
||||
private _compileModuleAndAllComponents<T>(moduleType: ConcreteType<T>, isSync: boolean):
|
||||
private _compileModuleAndAllComponents<T>(moduleType: Type<T>, isSync: boolean):
|
||||
SyncAsyncResult<ModuleWithComponentFactories<T>> {
|
||||
const componentPromise = this._compileComponents(moduleType, isSync);
|
||||
const ngModuleFactory = this._compileModule(moduleType);
|
||||
@@ -121,7 +120,7 @@ export class RuntimeCompiler implements Compiler {
|
||||
return new SyncAsyncResult(syncResult, asyncResult);
|
||||
}
|
||||
|
||||
private _compileModule<T>(moduleType: ConcreteType<T>): NgModuleFactory<T> {
|
||||
private _compileModule<T>(moduleType: Type<T>): NgModuleFactory<T> {
|
||||
let ngModuleFactory = this._compiledNgModuleCache.get(moduleType);
|
||||
if (!ngModuleFactory) {
|
||||
const moduleMeta = this._metadataResolver.getNgModuleMetadata(moduleType);
|
||||
@@ -156,9 +155,8 @@ export class RuntimeCompiler implements Compiler {
|
||||
return ngModuleFactory;
|
||||
}
|
||||
|
||||
private _compileComponentInModule<T>(
|
||||
compType: ConcreteType<T>, isSync: boolean,
|
||||
moduleType: ConcreteType<any>): SyncAsyncResult<ComponentFactory<T>> {
|
||||
private _compileComponentInModule<T>(compType: Type<T>, isSync: boolean, moduleType: Type<any>):
|
||||
SyncAsyncResult<ComponentFactory<T>> {
|
||||
this._metadataResolver.addComponentToModule(moduleType, compType);
|
||||
|
||||
const componentPromise = this._compileComponents(moduleType, isSync);
|
||||
@@ -171,7 +169,7 @@ export class RuntimeCompiler implements Compiler {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_compileComponents(mainModule: Type, isSync: boolean): Promise<any> {
|
||||
_compileComponents(mainModule: Type<any>, isSync: boolean): Promise<any> {
|
||||
const templates = new Set<CompiledTemplate>();
|
||||
var loadingPromises: Promise<any>[] = [];
|
||||
|
||||
@@ -208,7 +206,7 @@ export class RuntimeCompiler implements Compiler {
|
||||
}
|
||||
}
|
||||
|
||||
clearCacheFor(type: Type) {
|
||||
clearCacheFor(type: Type<any>) {
|
||||
this._compiledNgModuleCache.delete(type);
|
||||
this._metadataResolver.clearCacheFor(type);
|
||||
this._compiledHostTemplateCache.delete(type);
|
||||
@@ -227,7 +225,7 @@ export class RuntimeCompiler implements Compiler {
|
||||
this._compiledNgModuleCache.clear();
|
||||
}
|
||||
|
||||
private _createCompiledHostTemplate(compType: Type): CompiledTemplate {
|
||||
private _createCompiledHostTemplate(compType: Type<any>): CompiledTemplate {
|
||||
var compiledTemplate = this._compiledHostTemplateCache.get(compType);
|
||||
if (isBlank(compiledTemplate)) {
|
||||
var compMeta = this._metadataResolver.getDirectiveMetadata(compType);
|
||||
@@ -350,7 +348,7 @@ class CompiledTemplate {
|
||||
private _normalizedCompMeta: CompileDirectiveMetadata = null;
|
||||
isCompiled = false;
|
||||
isCompiledWithDeps = false;
|
||||
viewComponentTypes: Type[] = [];
|
||||
viewComponentTypes: Type<any>[] = [];
|
||||
viewDirectives: CompileDirectiveMetadata[] = [];
|
||||
|
||||
constructor(
|
||||
@@ -414,12 +412,12 @@ class ModuleBoundCompiler implements Compiler, ComponentResolver {
|
||||
private _warnOnComponentResolver = true;
|
||||
|
||||
constructor(
|
||||
private _delegate: RuntimeCompiler, private _ngModule: ConcreteType<any>,
|
||||
private _delegate: RuntimeCompiler, private _ngModule: Type<any>,
|
||||
private _parentComponentResolver: ComponentResolver, private _console: Console) {}
|
||||
|
||||
get _injector(): Injector { return this._delegate.injector; }
|
||||
|
||||
resolveComponent(component: Type|string): Promise<ComponentFactory<any>> {
|
||||
resolveComponent(component: Type<any>|string): Promise<ComponentFactory<any>> {
|
||||
if (isString(component)) {
|
||||
if (this._parentComponentResolver) {
|
||||
return this._parentComponentResolver.resolveComponent(component);
|
||||
@@ -432,32 +430,30 @@ class ModuleBoundCompiler implements Compiler, ComponentResolver {
|
||||
this._console.warn(ComponentResolver.DynamicCompilationDeprecationMsg);
|
||||
this._warnOnComponentResolver = false;
|
||||
}
|
||||
return this.compileComponentAsync(<ConcreteType<any>>component);
|
||||
return this.compileComponentAsync(<Type<any>>component);
|
||||
}
|
||||
|
||||
compileComponentAsync<T>(compType: ConcreteType<T>, ngModule: ConcreteType<any> = null):
|
||||
compileComponentAsync<T>(compType: Type<T>, ngModule: Type<any> = null):
|
||||
Promise<ComponentFactory<T>> {
|
||||
return this._delegate.compileComponentAsync(compType, ngModule ? ngModule : this._ngModule);
|
||||
}
|
||||
|
||||
compileComponentSync<T>(compType: ConcreteType<T>, ngModule: ConcreteType<any> = null):
|
||||
ComponentFactory<T> {
|
||||
compileComponentSync<T>(compType: Type<T>, ngModule: Type<any> = null): ComponentFactory<T> {
|
||||
return this._delegate.compileComponentSync(compType, ngModule ? ngModule : this._ngModule);
|
||||
}
|
||||
|
||||
compileModuleSync<T>(moduleType: ConcreteType<T>): NgModuleFactory<T> {
|
||||
compileModuleSync<T>(moduleType: Type<T>): NgModuleFactory<T> {
|
||||
return this._delegate.compileModuleSync(moduleType);
|
||||
}
|
||||
|
||||
compileModuleAsync<T>(moduleType: ConcreteType<T>): Promise<NgModuleFactory<T>> {
|
||||
compileModuleAsync<T>(moduleType: Type<T>): Promise<NgModuleFactory<T>> {
|
||||
return this._delegate.compileModuleAsync(moduleType);
|
||||
}
|
||||
compileModuleAndAllComponentsSync<T>(moduleType: ConcreteType<T>):
|
||||
ModuleWithComponentFactories<T> {
|
||||
compileModuleAndAllComponentsSync<T>(moduleType: Type<T>): ModuleWithComponentFactories<T> {
|
||||
return this._delegate.compileModuleAndAllComponentsSync(moduleType);
|
||||
}
|
||||
|
||||
compileModuleAndAllComponentsAsync<T>(moduleType: ConcreteType<T>):
|
||||
compileModuleAndAllComponentsAsync<T>(moduleType: Type<T>):
|
||||
Promise<ModuleWithComponentFactories<T>> {
|
||||
return this._delegate.compileModuleAndAllComponentsAsync(moduleType);
|
||||
}
|
||||
@@ -475,5 +471,5 @@ class ModuleBoundCompiler implements Compiler, ComponentResolver {
|
||||
/**
|
||||
* Clears the cache for the given component/ngModule.
|
||||
*/
|
||||
clearCacheFor(type: Type) { this._delegate.clearCacheFor(type); }
|
||||
clearCacheFor(type: Type<any>) { this._delegate.clearCacheFor(type); }
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
|
||||
import {DirectiveResolver, XHR} from '@angular/compiler';
|
||||
import {MockDirectiveResolver} from '@angular/compiler/testing';
|
||||
import {Compiler, Component, ComponentFactory, Injectable, Injector, Input, NgModule, NgModuleFactory, ViewMetadata} from '@angular/core';
|
||||
import {Compiler, Component, ComponentFactory, Injectable, Injector, Input, NgModule, NgModuleFactory, Type, ViewMetadata} from '@angular/core';
|
||||
import {ComponentFixture, TestBed, TestComponentBuilder, fakeAsync, tick} 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';
|
||||
|
||||
import {ConcreteType, stringify} from '../src/facade/lang';
|
||||
import {stringify} from '../src/facade/lang';
|
||||
|
||||
import {SpyXHR} from './spies';
|
||||
|
||||
|
||||
@@ -12,8 +12,7 @@ export * from './testing/directive_resolver_mock';
|
||||
export * from './testing/ng_module_resolver_mock';
|
||||
export * from './testing/pipe_resolver_mock';
|
||||
|
||||
import {ConcreteType, Type} from './src/facade/lang';
|
||||
import {createPlatformFactory, ModuleWithComponentFactories, Injectable, CompilerOptions, COMPILER_OPTIONS, PlatformRef, CompilerFactory, ComponentFactory, NgModuleFactory, Injector, NgModuleMetadata, NgModuleMetadataType, ComponentMetadata, ComponentMetadataType, DirectiveMetadata, DirectiveMetadataType, PipeMetadata, PipeMetadataType} from '@angular/core';
|
||||
import {createPlatformFactory, ModuleWithComponentFactories, Injectable, CompilerOptions, COMPILER_OPTIONS, CompilerFactory, ComponentFactory, NgModuleFactory, Injector, NgModuleMetadata, NgModuleMetadataType, ComponentMetadata, ComponentMetadataType, DirectiveMetadata, DirectiveMetadataType, PipeMetadata, PipeMetadataType, Type, PlatformRef} from '@angular/core';
|
||||
import {MetadataOverride} from '@angular/core/testing';
|
||||
import {TestingCompilerFactory, TestingCompiler} from './core_private_testing';
|
||||
import {platformCoreDynamic, RuntimeCompiler, DirectiveResolver, NgModuleResolver, PipeResolver} from './index';
|
||||
@@ -40,55 +39,51 @@ export class TestingCompilerImpl implements TestingCompiler {
|
||||
private _compiler: RuntimeCompiler, private _directiveResolver: MockDirectiveResolver,
|
||||
private _pipeResolver: MockPipeResolver, private _moduleResolver: MockNgModuleResolver) {}
|
||||
get injector(): Injector { return this._compiler.injector; }
|
||||
compileComponentAsync<T>(component: ConcreteType<T>, ngModule: Type = null):
|
||||
compileComponentAsync<T>(component: Type<T>, ngModule: Type<any> = null):
|
||||
Promise<ComponentFactory<T>> {
|
||||
return this._compiler.compileComponentAsync(component, <any>ngModule);
|
||||
}
|
||||
compileComponentSync<T>(component: ConcreteType<T>, ngModule: Type = null): ComponentFactory<T> {
|
||||
compileComponentSync<T>(component: Type<T>, ngModule: Type<any> = null): ComponentFactory<T> {
|
||||
return this._compiler.compileComponentSync(component, <any>ngModule);
|
||||
}
|
||||
compileModuleSync<T>(moduleType: ConcreteType<T>): NgModuleFactory<T> {
|
||||
compileModuleSync<T>(moduleType: Type<T>): NgModuleFactory<T> {
|
||||
return this._compiler.compileModuleSync(moduleType);
|
||||
}
|
||||
|
||||
compileModuleAsync<T>(moduleType: ConcreteType<T>): Promise<NgModuleFactory<T>> {
|
||||
compileModuleAsync<T>(moduleType: Type<T>): Promise<NgModuleFactory<T>> {
|
||||
return this._compiler.compileModuleAsync(moduleType);
|
||||
}
|
||||
compileModuleAndAllComponentsSync<T>(moduleType: ConcreteType<T>):
|
||||
ModuleWithComponentFactories<T> {
|
||||
compileModuleAndAllComponentsSync<T>(moduleType: Type<T>): ModuleWithComponentFactories<T> {
|
||||
return this._compiler.compileModuleAndAllComponentsSync(moduleType);
|
||||
}
|
||||
|
||||
compileModuleAndAllComponentsAsync<T>(moduleType: ConcreteType<T>):
|
||||
compileModuleAndAllComponentsAsync<T>(moduleType: Type<T>):
|
||||
Promise<ModuleWithComponentFactories<T>> {
|
||||
return this._compiler.compileModuleAndAllComponentsAsync(moduleType);
|
||||
}
|
||||
|
||||
overrideModule(ngModule: ConcreteType<any>, override: MetadataOverride<NgModuleMetadataType>):
|
||||
void {
|
||||
overrideModule(ngModule: Type<any>, override: MetadataOverride<NgModuleMetadataType>): void {
|
||||
const oldMetadata = this._moduleResolver.resolve(ngModule, false);
|
||||
this._moduleResolver.setNgModule(
|
||||
ngModule, this._overrider.overrideMetadata(NgModuleMetadata, oldMetadata, override));
|
||||
}
|
||||
overrideDirective(
|
||||
directive: ConcreteType<any>, override: MetadataOverride<DirectiveMetadataType>): void {
|
||||
overrideDirective(directive: Type<any>, override: MetadataOverride<DirectiveMetadataType>): void {
|
||||
const oldMetadata = this._directiveResolver.resolve(directive, false);
|
||||
this._directiveResolver.setDirective(
|
||||
directive, this._overrider.overrideMetadata(DirectiveMetadata, oldMetadata, override));
|
||||
}
|
||||
overrideComponent(
|
||||
component: ConcreteType<any>, override: MetadataOverride<ComponentMetadataType>): void {
|
||||
overrideComponent(component: Type<any>, override: MetadataOverride<ComponentMetadataType>): void {
|
||||
const oldMetadata = this._directiveResolver.resolve(component, false);
|
||||
this._directiveResolver.setDirective(
|
||||
component, this._overrider.overrideMetadata(ComponentMetadata, oldMetadata, override));
|
||||
}
|
||||
overridePipe(pipe: ConcreteType<any>, override: MetadataOverride<PipeMetadataType>): void {
|
||||
overridePipe(pipe: Type<any>, override: MetadataOverride<PipeMetadataType>): void {
|
||||
const oldMetadata = this._pipeResolver.resolve(pipe, false);
|
||||
this._pipeResolver.setPipe(
|
||||
pipe, this._overrider.overrideMetadata(PipeMetadata, oldMetadata, override));
|
||||
}
|
||||
clearCache(): void { this._compiler.clearCache(); }
|
||||
clearCacheFor(type: Type) { this._compiler.clearCacheFor(type); }
|
||||
clearCacheFor(type: Type<any>) { this._compiler.clearCacheFor(type); }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,7 +91,7 @@ export class TestingCompilerImpl implements TestingCompiler {
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
export const platformCoreDynamicTesting =
|
||||
export const platformCoreDynamicTesting: (extraProviders?: any[]) => PlatformRef =
|
||||
createPlatformFactory(platformCoreDynamic, 'coreDynamicTesting', [
|
||||
{
|
||||
provide: COMPILER_OPTIONS,
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {AnimationEntryMetadata, BaseException, Compiler, ComponentMetadata, DirectiveMetadata, Injectable, Injector, ViewMetadata, resolveForwardRef} from '@angular/core';
|
||||
import {AnimationEntryMetadata, Compiler, ComponentMetadata, DirectiveMetadata, Injectable, Injector, Type, ViewMetadata, resolveForwardRef} from '@angular/core';
|
||||
|
||||
import {DirectiveResolver} from '../src/directive_resolver';
|
||||
import {Map} from '../src/facade/collection';
|
||||
import {Type, isArray, isPresent, stringify} from '../src/facade/lang';
|
||||
import {BaseException} from '../src/facade/exceptions';
|
||||
import {isArray, isPresent, stringify} from '../src/facade/lang';
|
||||
|
||||
|
||||
|
||||
@@ -20,21 +21,21 @@ import {Type, isArray, isPresent, stringify} from '../src/facade/lang';
|
||||
*/
|
||||
@Injectable()
|
||||
export class MockDirectiveResolver extends DirectiveResolver {
|
||||
private _directives = new Map<Type, DirectiveMetadata>();
|
||||
private _providerOverrides = new Map<Type, any[]>();
|
||||
private _viewProviderOverrides = new Map<Type, any[]>();
|
||||
private _views = new Map<Type, ViewMetadata>();
|
||||
private _inlineTemplates = new Map<Type, string>();
|
||||
private _animations = new Map<Type, AnimationEntryMetadata[]>();
|
||||
private _directiveOverrides = new Map<Type, Map<Type, Type>>();
|
||||
private _directives = new Map<Type<any>, DirectiveMetadata>();
|
||||
private _providerOverrides = new Map<Type<any>, any[]>();
|
||||
private _viewProviderOverrides = new Map<Type<any>, any[]>();
|
||||
private _views = new Map<Type<any>, ViewMetadata>();
|
||||
private _inlineTemplates = new Map<Type<any>, string>();
|
||||
private _animations = new Map<Type<any>, AnimationEntryMetadata[]>();
|
||||
private _directiveOverrides = new Map<Type<any>, Map<Type<any>, Type<any>>>();
|
||||
|
||||
constructor(private _injector: Injector) { super(); }
|
||||
|
||||
private get _compiler(): Compiler { return this._injector.get(Compiler); }
|
||||
|
||||
private _clearCacheFor(component: Type) { this._compiler.clearCacheFor(component); }
|
||||
private _clearCacheFor(component: Type<any>) { this._compiler.clearCacheFor(component); }
|
||||
|
||||
resolve(type: Type, throwIfNotFound = true): DirectiveMetadata {
|
||||
resolve(type: Type<any>, throwIfNotFound = true): DirectiveMetadata {
|
||||
let metadata = this._directives.get(type);
|
||||
if (!metadata) {
|
||||
metadata = super.resolve(type, throwIfNotFound);
|
||||
@@ -134,17 +135,17 @@ export class MockDirectiveResolver extends DirectiveResolver {
|
||||
/**
|
||||
* Overrides the {@link DirectiveMetadata} for a directive.
|
||||
*/
|
||||
setDirective(type: Type, metadata: DirectiveMetadata): void {
|
||||
setDirective(type: Type<any>, metadata: DirectiveMetadata): void {
|
||||
this._directives.set(type, metadata);
|
||||
this._clearCacheFor(type);
|
||||
}
|
||||
|
||||
setProvidersOverride(type: Type, providers: any[]): void {
|
||||
setProvidersOverride(type: Type<any>, providers: any[]): void {
|
||||
this._providerOverrides.set(type, providers);
|
||||
this._clearCacheFor(type);
|
||||
}
|
||||
|
||||
setViewProvidersOverride(type: Type, viewProviders: any[]): void {
|
||||
setViewProvidersOverride(type: Type<any>, viewProviders: any[]): void {
|
||||
this._viewProviderOverrides.set(type, viewProviders);
|
||||
this._clearCacheFor(type);
|
||||
}
|
||||
@@ -152,19 +153,19 @@ export class MockDirectiveResolver extends DirectiveResolver {
|
||||
/**
|
||||
* Overrides the {@link ViewMetadata} for a component.
|
||||
*/
|
||||
setView(component: Type, view: ViewMetadata): void {
|
||||
setView(component: Type<any>, view: ViewMetadata): void {
|
||||
this._views.set(component, view);
|
||||
this._clearCacheFor(component);
|
||||
}
|
||||
/**
|
||||
* Overrides the inline template for a component - other configuration remains unchanged.
|
||||
*/
|
||||
setInlineTemplate(component: Type, template: string): void {
|
||||
setInlineTemplate(component: Type<any>, template: string): void {
|
||||
this._inlineTemplates.set(component, template);
|
||||
this._clearCacheFor(component);
|
||||
}
|
||||
|
||||
setAnimations(component: Type, animations: AnimationEntryMetadata[]): void {
|
||||
setAnimations(component: Type<any>, animations: AnimationEntryMetadata[]): void {
|
||||
this._animations.set(component, animations);
|
||||
this._clearCacheFor(component);
|
||||
}
|
||||
@@ -172,11 +173,11 @@ export class MockDirectiveResolver extends DirectiveResolver {
|
||||
/**
|
||||
* Overrides a directive from the component {@link ViewMetadata}.
|
||||
*/
|
||||
overrideViewDirective(component: Type, from: Type, to: Type): void {
|
||||
overrideViewDirective(component: Type<any>, from: Type<any>, to: Type<any>): void {
|
||||
var overrides = this._directiveOverrides.get(component);
|
||||
|
||||
if (!overrides) {
|
||||
overrides = new Map<Type, Type>();
|
||||
overrides = new Map<Type<any>, Type<any>>();
|
||||
this._directiveOverrides.set(component, overrides);
|
||||
}
|
||||
|
||||
@@ -185,7 +186,7 @@ export class MockDirectiveResolver extends DirectiveResolver {
|
||||
}
|
||||
}
|
||||
|
||||
function flattenArray(tree: any[], out: Array<Type|any[]>): void {
|
||||
function flattenArray(tree: any[], out: Array<Type<any>|any[]>): void {
|
||||
if (!isPresent(tree)) return;
|
||||
for (var i = 0; i < tree.length; i++) {
|
||||
var item = resolveForwardRef(tree[i]);
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {BaseException} from '@angular/core';
|
||||
import {MetadataOverride} from '@angular/core/testing';
|
||||
|
||||
import {ConcreteType, stringify} from '../src/facade/lang';
|
||||
import {BaseException} from '../src/facade/exceptions';
|
||||
import {stringify} from '../src/facade/lang';
|
||||
|
||||
type StringMap = {
|
||||
[key: string]: any
|
||||
|
||||
@@ -13,18 +13,18 @@ import {Map} from '../src/facade/collection';
|
||||
|
||||
@Injectable()
|
||||
export class MockNgModuleResolver extends NgModuleResolver {
|
||||
private _ngModules = new Map<Type, NgModuleMetadata>();
|
||||
private _ngModules = new Map<Type<any>, NgModuleMetadata>();
|
||||
|
||||
constructor(private _injector: Injector) { super(); }
|
||||
|
||||
private get _compiler(): Compiler { return this._injector.get(Compiler); }
|
||||
|
||||
private _clearCacheFor(component: Type) { this._compiler.clearCacheFor(component); }
|
||||
private _clearCacheFor(component: Type<any>) { this._compiler.clearCacheFor(component); }
|
||||
|
||||
/**
|
||||
* Overrides the {@link NgModuleMetadata} for a module.
|
||||
*/
|
||||
setNgModule(type: Type, metadata: NgModuleMetadata): void {
|
||||
setNgModule(type: Type<any>, metadata: NgModuleMetadata): void {
|
||||
this._ngModules.set(type, metadata);
|
||||
this._clearCacheFor(type);
|
||||
}
|
||||
@@ -35,7 +35,7 @@ export class MockNgModuleResolver extends NgModuleResolver {
|
||||
* default
|
||||
* `NgModuleResolver`, see `setNgModule`.
|
||||
*/
|
||||
resolve(type: Type, throwIfNotFound = true): NgModuleMetadata {
|
||||
resolve(type: Type<any>, throwIfNotFound = true): NgModuleMetadata {
|
||||
var metadata = this._ngModules.get(type);
|
||||
if (!metadata) {
|
||||
metadata = super.resolve(type, throwIfNotFound);
|
||||
|
||||
@@ -13,18 +13,18 @@ import {Map} from '../src/facade/collection';
|
||||
|
||||
@Injectable()
|
||||
export class MockPipeResolver extends PipeResolver {
|
||||
private _pipes = new Map<Type, PipeMetadata>();
|
||||
private _pipes = new Map<Type<any>, PipeMetadata>();
|
||||
|
||||
constructor(private _injector: Injector) { super(); }
|
||||
|
||||
private get _compiler(): Compiler { return this._injector.get(Compiler); }
|
||||
|
||||
private _clearCacheFor(pipe: Type) { this._compiler.clearCacheFor(pipe); }
|
||||
private _clearCacheFor(pipe: Type<any>) { this._compiler.clearCacheFor(pipe); }
|
||||
|
||||
/**
|
||||
* Overrides the {@link PipeMetadata} for a pipe.
|
||||
*/
|
||||
setPipe(type: Type, metadata: PipeMetadata): void {
|
||||
setPipe(type: Type<any>, metadata: PipeMetadata): void {
|
||||
this._pipes.set(type, metadata);
|
||||
this._clearCacheFor(type);
|
||||
}
|
||||
@@ -35,7 +35,7 @@ export class MockPipeResolver extends PipeResolver {
|
||||
* default
|
||||
* `PipeResolver`, see `setPipe`.
|
||||
*/
|
||||
resolve(type: Type, throwIfNotFound = true): PipeMetadata {
|
||||
resolve(type: Type<any>, throwIfNotFound = true): PipeMetadata {
|
||||
var metadata = this._pipes.get(type);
|
||||
if (!metadata) {
|
||||
metadata = super.resolve(type, throwIfNotFound);
|
||||
|
||||
@@ -6,12 +6,13 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {AnimationEntryMetadata, Compiler, ComponentFactory, Inject, Injectable, Injector, NgZone, ViewMetadata} from '@angular/core';
|
||||
import {AnimationEntryMetadata, Compiler, ComponentFactory, Inject, Injectable, Injector, NgZone, Type, ViewMetadata} from '@angular/core';
|
||||
import {ComponentFixture, ComponentFixtureNoNgZone, TestBed, TestComponentBuilder} from '@angular/core/testing';
|
||||
|
||||
import {DirectiveResolver} from '../index';
|
||||
import {MapWrapper} from '../src/facade/collection';
|
||||
import {ConcreteType, Type, isPresent} from '../src/facade/lang';
|
||||
import {isPresent} from '../src/facade/lang';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -23,17 +24,17 @@ import {ConcreteType, Type, isPresent} from '../src/facade/lang';
|
||||
@Injectable()
|
||||
export class OverridingTestComponentBuilder extends TestComponentBuilder {
|
||||
/** @internal */
|
||||
_bindingsOverrides = new Map<Type, any[]>();
|
||||
_bindingsOverrides = new Map<Type<any>, any[]>();
|
||||
/** @internal */
|
||||
_directiveOverrides = new Map<Type, Map<Type, Type>>();
|
||||
_directiveOverrides = new Map<Type<any>, Map<Type<any>, Type<any>>>();
|
||||
/** @internal */
|
||||
_templateOverrides = new Map<Type, string>();
|
||||
_templateOverrides = new Map<Type<any>, string>();
|
||||
/** @internal */
|
||||
_animationOverrides = new Map<Type, AnimationEntryMetadata[]>();
|
||||
_animationOverrides = new Map<Type<any>, AnimationEntryMetadata[]>();
|
||||
/** @internal */
|
||||
_viewBindingsOverrides = new Map<Type, any[]>();
|
||||
_viewBindingsOverrides = new Map<Type<any>, any[]>();
|
||||
/** @internal */
|
||||
_viewOverrides = new Map<Type, ViewMetadata>();
|
||||
_viewOverrides = new Map<Type<any>, ViewMetadata>();
|
||||
|
||||
constructor(@Inject(TestBed) injector: Injector) { super(injector); }
|
||||
|
||||
@@ -48,54 +49,55 @@ export class OverridingTestComponentBuilder extends TestComponentBuilder {
|
||||
return clone;
|
||||
}
|
||||
|
||||
overrideTemplate(componentType: Type, template: string): OverridingTestComponentBuilder {
|
||||
overrideTemplate(componentType: Type<any>, template: string): OverridingTestComponentBuilder {
|
||||
let clone = this._clone();
|
||||
clone._templateOverrides.set(componentType, template);
|
||||
return clone;
|
||||
}
|
||||
|
||||
overrideAnimations(componentType: Type, animations: AnimationEntryMetadata[]):
|
||||
overrideAnimations(componentType: Type<any>, animations: AnimationEntryMetadata[]):
|
||||
TestComponentBuilder {
|
||||
var clone = this._clone();
|
||||
clone._animationOverrides.set(componentType, animations);
|
||||
return clone;
|
||||
}
|
||||
|
||||
overrideView(componentType: Type, view: ViewMetadata): OverridingTestComponentBuilder {
|
||||
overrideView(componentType: Type<any>, view: ViewMetadata): OverridingTestComponentBuilder {
|
||||
let clone = this._clone();
|
||||
clone._viewOverrides.set(componentType, view);
|
||||
return clone;
|
||||
}
|
||||
|
||||
overrideDirective(componentType: Type, from: Type, to: Type): OverridingTestComponentBuilder {
|
||||
overrideDirective(componentType: Type<any>, from: Type<any>, to: Type<any>):
|
||||
OverridingTestComponentBuilder {
|
||||
let clone = this._clone();
|
||||
let overridesForComponent = clone._directiveOverrides.get(componentType);
|
||||
if (!isPresent(overridesForComponent)) {
|
||||
clone._directiveOverrides.set(componentType, new Map<Type, Type>());
|
||||
clone._directiveOverrides.set(componentType, new Map<Type<any>, Type<any>>());
|
||||
overridesForComponent = clone._directiveOverrides.get(componentType);
|
||||
}
|
||||
overridesForComponent.set(from, to);
|
||||
return clone;
|
||||
}
|
||||
|
||||
overrideProviders(type: Type, providers: any[]): OverridingTestComponentBuilder {
|
||||
overrideProviders(type: Type<any>, providers: any[]): OverridingTestComponentBuilder {
|
||||
let clone = this._clone();
|
||||
clone._bindingsOverrides.set(type, providers);
|
||||
return clone;
|
||||
}
|
||||
|
||||
overrideViewProviders(type: Type, providers: any[]): OverridingTestComponentBuilder {
|
||||
overrideViewProviders(type: Type<any>, providers: any[]): OverridingTestComponentBuilder {
|
||||
let clone = this._clone();
|
||||
clone._viewBindingsOverrides.set(type, providers);
|
||||
return clone;
|
||||
}
|
||||
|
||||
createAsync<T>(rootComponentType: ConcreteType<T>): Promise<ComponentFixture<T>> {
|
||||
createAsync<T>(rootComponentType: Type<T>): Promise<ComponentFixture<T>> {
|
||||
this._applyMetadataOverrides();
|
||||
return super.createAsync(rootComponentType);
|
||||
}
|
||||
|
||||
createSync<T>(rootComponentType: ConcreteType<T>): ComponentFixture<T> {
|
||||
createSync<T>(rootComponentType: Type<T>): ComponentFixture<T> {
|
||||
this._applyMetadataOverrides();
|
||||
return super.createSync(rootComponentType);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ export * from './src/platform_core_providers';
|
||||
export {APPLICATION_COMMON_PROVIDERS, ApplicationModule} from './src/application_module';
|
||||
export {wtfCreateScope, wtfLeave, wtfStartTimeRange, wtfEndTimeRange, WtfScopeFn} from './src/profile/profile';
|
||||
|
||||
export {Type} from './src/facade/lang';
|
||||
export {Type} from './src/type';
|
||||
export {EventEmitter} from './src/facade/async';
|
||||
export {ExceptionHandler, WrappedException, BaseException} from './src/facade/exceptions';
|
||||
export * from './private_export';
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../src/facade/lang';
|
||||
|
||||
import {ApplicationInitStatus} from './application_init';
|
||||
import {ApplicationRef, ApplicationRef_, isDevMode} from './application_ref';
|
||||
import {APP_ID_RANDOM_PROVIDER} from './application_tokens';
|
||||
@@ -18,6 +16,7 @@ import {ComponentResolver} from './linker/component_resolver';
|
||||
import {DynamicComponentLoader, DynamicComponentLoader_} from './linker/dynamic_component_loader';
|
||||
import {ViewUtils} from './linker/view_utils';
|
||||
import {NgModule} from './metadata';
|
||||
import {Type} from './type';
|
||||
|
||||
export function _iterableDiffersFactory() {
|
||||
return defaultIterableDiffers;
|
||||
@@ -33,7 +32,7 @@ export function _keyValueDiffersFactory() {
|
||||
*
|
||||
* @deprecated Include `ApplicationModule` instead.
|
||||
*/
|
||||
export const APPLICATION_COMMON_PROVIDERS: Array<Type|{[k: string]: any}|any[]> = [];
|
||||
export const APPLICATION_COMMON_PROVIDERS: Array<Type<any>|{[k: string]: any}|any[]> = [];
|
||||
|
||||
/**
|
||||
* This module includes the providers of @angular/core that are needed
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import {ListWrapper} from '../src/facade/collection';
|
||||
import {BaseException, ExceptionHandler, unimplemented} from '../src/facade/exceptions';
|
||||
import {ConcreteType, Type, isBlank, isPresent, isPromise, stringify} from '../src/facade/lang';
|
||||
import {isBlank, isPresent, isPromise, stringify} from '../src/facade/lang';
|
||||
|
||||
import {ApplicationInitStatus} from './application_init';
|
||||
import {APP_BOOTSTRAP_LISTENER, PLATFORM_INITIALIZER} from './application_tokens';
|
||||
@@ -22,6 +22,7 @@ import {ComponentResolver} from './linker/component_resolver';
|
||||
import {NgModuleFactory, NgModuleInjector, NgModuleRef} from './linker/ng_module_factory';
|
||||
import {WtfScopeFn, wtfCreateScope, wtfLeave} from './profile/profile';
|
||||
import {Testability, TestabilityRegistry} from './testability/testability';
|
||||
import {Type} from './type';
|
||||
import {NgZone, NgZoneError} from './zone/ng_zone';
|
||||
|
||||
var _devMode: boolean = true;
|
||||
@@ -182,7 +183,7 @@ export function coreBootstrap<C>(
|
||||
* @deprecated Use {@link bootstrapModule} instead.
|
||||
*/
|
||||
export function coreLoadAndBootstrap(
|
||||
componentType: Type, injector: Injector): Promise<ComponentRef<any>> {
|
||||
componentType: Type<any>, injector: Injector): Promise<ComponentRef<any>> {
|
||||
throw new BaseException('coreLoadAndBootstrap is deprecated. Use bootstrapModule instead.');
|
||||
}
|
||||
|
||||
@@ -239,9 +240,8 @@ export abstract class PlatformRef {
|
||||
* ```
|
||||
* @stable
|
||||
*/
|
||||
bootstrapModule<M>(
|
||||
moduleType: ConcreteType<M>,
|
||||
compilerOptions: CompilerOptions|CompilerOptions[] = []): Promise<NgModuleRef<M>> {
|
||||
bootstrapModule<M>(moduleType: Type<M>, compilerOptions: CompilerOptions|CompilerOptions[] = []):
|
||||
Promise<NgModuleRef<M>> {
|
||||
throw unimplemented();
|
||||
}
|
||||
|
||||
@@ -373,14 +373,13 @@ export class PlatformRef_ extends PlatformRef {
|
||||
});
|
||||
}
|
||||
|
||||
bootstrapModule<M>(
|
||||
moduleType: ConcreteType<M>,
|
||||
compilerOptions: CompilerOptions|CompilerOptions[] = []): Promise<NgModuleRef<M>> {
|
||||
bootstrapModule<M>(moduleType: Type<M>, compilerOptions: CompilerOptions|CompilerOptions[] = []):
|
||||
Promise<NgModuleRef<M>> {
|
||||
return this._bootstrapModuleWithZone(moduleType, compilerOptions, null);
|
||||
}
|
||||
|
||||
private _bootstrapModuleWithZone<M>(
|
||||
moduleType: ConcreteType<M>, compilerOptions: CompilerOptions|CompilerOptions[] = [],
|
||||
moduleType: Type<M>, compilerOptions: CompilerOptions|CompilerOptions[] = [],
|
||||
ngZone: NgZone): Promise<NgModuleRef<M>> {
|
||||
const compilerFactory: CompilerFactory = this.injector.get(CompilerFactory);
|
||||
const compiler = compilerFactory.createCompiler(
|
||||
@@ -455,7 +454,7 @@ export abstract class ApplicationRef {
|
||||
* ### Example
|
||||
* {@example core/ts/platform/platform.ts region='longform'}
|
||||
*/
|
||||
abstract bootstrap<C>(componentFactory: ComponentFactory<C>|ConcreteType<C>): ComponentRef<C>;
|
||||
abstract bootstrap<C>(componentFactory: ComponentFactory<C>|Type<C>): ComponentRef<C>;
|
||||
|
||||
/**
|
||||
* Retrieve the application {@link Injector}.
|
||||
@@ -496,7 +495,7 @@ export abstract class ApplicationRef {
|
||||
* Get a list of component types registered to this application.
|
||||
* This list is populated even before the component is created.
|
||||
*/
|
||||
get componentTypes(): Type[] { return <Type[]>unimplemented(); };
|
||||
get componentTypes(): Type<any>[] { return <Type<any>[]>unimplemented(); };
|
||||
|
||||
/**
|
||||
* Get a list of components registered to this application.
|
||||
@@ -515,7 +514,7 @@ export class ApplicationRef_ extends ApplicationRef {
|
||||
*/
|
||||
private _disposeListeners: Function[] = [];
|
||||
private _rootComponents: ComponentRef<any>[] = [];
|
||||
private _rootComponentTypes: Type[] = [];
|
||||
private _rootComponentTypes: Type<any>[] = [];
|
||||
private _changeDetectorRefs: ChangeDetectorRef[] = [];
|
||||
private _runningTick: boolean = false;
|
||||
private _enforceNoNewChanges: boolean = false;
|
||||
@@ -567,7 +566,7 @@ export class ApplicationRef_ extends ApplicationRef {
|
||||
() => _callAndReportToExceptionHandler(this._exceptionHandler, <any>callback));
|
||||
}
|
||||
|
||||
bootstrap<C>(componentOrFactory: ComponentFactory<C>|ConcreteType<C>): ComponentRef<C> {
|
||||
bootstrap<C>(componentOrFactory: ComponentFactory<C>|Type<C>): ComponentRef<C> {
|
||||
if (!this._initStatus.done) {
|
||||
throw new BaseException(
|
||||
'Cannot bootstrap as there are still asynchronous initializers running. Bootstrap components in the `ngDoBootstrap` method of the root module.');
|
||||
@@ -655,7 +654,7 @@ export class ApplicationRef_ extends ApplicationRef {
|
||||
*/
|
||||
dispose(): void { this.ngOnDestroy(); }
|
||||
|
||||
get componentTypes(): Type[] { return this._rootComponentTypes; }
|
||||
get componentTypes(): Type<any>[] { return this._rootComponentTypes; }
|
||||
|
||||
get components(): ComponentRef<any>[] { return this._rootComponents; }
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type, isFunction, stringify} from '../facade/lang';
|
||||
import {isFunction, stringify} from '../facade/lang';
|
||||
import {Type} from '../type';
|
||||
|
||||
|
||||
/**
|
||||
@@ -31,10 +32,10 @@ export interface ForwardRefFn { (): any; }
|
||||
* {@example core/di/ts/forward_ref/forward_ref.ts region='forward_ref'}
|
||||
* @experimental
|
||||
*/
|
||||
export function forwardRef(forwardRefFn: ForwardRefFn): Type {
|
||||
export function forwardRef(forwardRefFn: ForwardRefFn): Type<any> {
|
||||
(<any>forwardRefFn).__forward_ref__ = forwardRef;
|
||||
(<any>forwardRefFn).toString = function() { return stringify(this()); };
|
||||
return (<Type><any>forwardRefFn);
|
||||
return (<Type<any>><any>forwardRefFn);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
*/
|
||||
|
||||
import {BaseException} from '../facade/exceptions';
|
||||
import {Type, isBlank, isFunction, isType, normalizeBool, stringify} from '../facade/lang';
|
||||
import {isBlank, isFunction, isType, normalizeBool, stringify} from '../facade/lang';
|
||||
import {Type} from '../type';
|
||||
|
||||
|
||||
/**
|
||||
@@ -61,7 +62,7 @@ export class Provider {
|
||||
* expect(injectorAlias.get(Vehicle) instanceof Car).toBe(true);
|
||||
* ```
|
||||
*/
|
||||
useClass: Type;
|
||||
useClass: Type<any>;
|
||||
|
||||
/**
|
||||
* Binds a DI token to a value.
|
||||
@@ -157,7 +158,7 @@ export class Provider {
|
||||
_multi: boolean;
|
||||
|
||||
constructor(token: any, {useClass, useValue, useExisting, useFactory, deps, multi}: {
|
||||
useClass?: Type,
|
||||
useClass?: Type<any>,
|
||||
useValue?: any,
|
||||
useExisting?: any,
|
||||
useFactory?: Function,
|
||||
@@ -213,7 +214,7 @@ export class Provider {
|
||||
*/
|
||||
export class Binding extends Provider {
|
||||
constructor(token: any, {toClass, toValue, toAlias, toFactory, deps, multi}: {
|
||||
toClass?: Type,
|
||||
toClass?: Type<any>,
|
||||
toValue?: any,
|
||||
toAlias?: any,
|
||||
toFactory: Function, deps?: Object[], multi?: boolean
|
||||
@@ -301,7 +302,7 @@ export class ProviderBuilder {
|
||||
* expect(injectorAlias.get(Vehicle) instanceof Car).toBe(true);
|
||||
* ```
|
||||
*/
|
||||
toClass(type: Type): Provider {
|
||||
toClass(type: Type<any>): Provider {
|
||||
if (!isType(type)) {
|
||||
throw new BaseException(
|
||||
`Trying to create a class provider but "${stringify(type)}" is not a class!`);
|
||||
@@ -396,7 +397,7 @@ export class ProviderBuilder {
|
||||
* @deprecated
|
||||
*/
|
||||
export function provide(token: any, {useClass, useValue, useExisting, useFactory, deps, multi}: {
|
||||
useClass?: Type,
|
||||
useClass?: Type<any>,
|
||||
useValue?: any,
|
||||
useExisting?: any,
|
||||
useFactory?: Function,
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
import {ListWrapper} from '../facade/collection';
|
||||
import {BaseException, WrappedException} from '../facade/exceptions';
|
||||
import {Type, isBlank, stringify} from '../facade/lang';
|
||||
import {isBlank, stringify} from '../facade/lang';
|
||||
import {Type} from '../type';
|
||||
|
||||
import {Provider} from './provider';
|
||||
import {ReflectiveInjector} from './reflective_injector';
|
||||
@@ -225,11 +226,11 @@ export class InvalidProviderError extends BaseException {
|
||||
* @stable
|
||||
*/
|
||||
export class NoAnnotationError extends BaseException {
|
||||
constructor(typeOrFunc: Type|Function, params: any[][]) {
|
||||
constructor(typeOrFunc: Type<any>|Function, params: any[][]) {
|
||||
super(NoAnnotationError._genMessage(typeOrFunc, params));
|
||||
}
|
||||
|
||||
private static _genMessage(typeOrFunc: Type|Function, params: any[][]) {
|
||||
private static _genMessage(typeOrFunc: Type<any>|Function, params: any[][]) {
|
||||
var signature: string[] = [];
|
||||
for (var i = 0, ii = params.length; i < ii; i++) {
|
||||
var parameter = params[i];
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import {ListWrapper} from '../facade/collection';
|
||||
import {BaseException, unimplemented} from '../facade/exceptions';
|
||||
import {Type} from '../facade/lang';
|
||||
import {Type} from '../type';
|
||||
|
||||
import {Injector, THROW_IF_NOT_FOUND} from './injector';
|
||||
import {SelfMetadata, SkipSelfMetadata} from './metadata';
|
||||
@@ -17,7 +17,7 @@ import {AbstractProviderError, CyclicDependencyError, InstantiationError, NoProv
|
||||
import {ReflectiveKey} from './reflective_key';
|
||||
import {ReflectiveDependency, ResolvedReflectiveFactory, ResolvedReflectiveProvider, resolveReflectiveProviders} from './reflective_provider';
|
||||
|
||||
var __unused: Type; // avoid unused import when Type union types are erased
|
||||
var __unused: Type<any>; // avoid unused import when Type union types are erased
|
||||
|
||||
// Threshold for the dynamic version
|
||||
const _MAX_CONSTRUCTION_COUNTER = 10;
|
||||
@@ -392,7 +392,7 @@ export abstract class ReflectiveInjector implements Injector {
|
||||
*
|
||||
* See {@link ReflectiveInjector#fromResolvedProviders} for more info.
|
||||
*/
|
||||
static resolve(providers: Array<Type|Provider|{[k: string]: any}|any[]>):
|
||||
static resolve(providers: Array<Type<any>|Provider|{[k: string]: any}|any[]>):
|
||||
ResolvedReflectiveProvider[] {
|
||||
return resolveReflectiveProviders(providers);
|
||||
}
|
||||
@@ -424,7 +424,7 @@ export abstract class ReflectiveInjector implements Injector {
|
||||
* See {@link Injector#resolve} and {@link Injector#fromResolvedProviders}.
|
||||
*/
|
||||
static resolveAndCreate(
|
||||
providers: Array<Type|Provider|{[k: string]: any}|any[]>,
|
||||
providers: Array<Type<any>|Provider|{[k: string]: any}|any[]>,
|
||||
parent: Injector = null): ReflectiveInjector {
|
||||
var ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
|
||||
return ReflectiveInjector.fromResolvedProviders(ResolvedReflectiveProviders, parent);
|
||||
@@ -516,7 +516,7 @@ export abstract class ReflectiveInjector implements Injector {
|
||||
* because it needs to resolve the passed-in providers first.
|
||||
* See {@link Injector#resolve} and {@link Injector#createChildFromResolved}.
|
||||
*/
|
||||
resolveAndCreateChild(providers: Array<Type|Provider|{[k: string]: any}|any[]>):
|
||||
resolveAndCreateChild(providers: Array<Type<any>|Provider|{[k: string]: any}|any[]>):
|
||||
ReflectiveInjector {
|
||||
return unimplemented();
|
||||
}
|
||||
@@ -574,7 +574,7 @@ export abstract class ReflectiveInjector implements Injector {
|
||||
* expect(car).not.toBe(injector.resolveAndInstantiate(Car));
|
||||
* ```
|
||||
*/
|
||||
resolveAndInstantiate(provider: Type|Provider): any { return unimplemented(); }
|
||||
resolveAndInstantiate(provider: Type<any>|Provider): any { return unimplemented(); }
|
||||
|
||||
/**
|
||||
* Instantiates an object using a resolved provider in the context of the injector.
|
||||
@@ -644,7 +644,7 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
*/
|
||||
get internalStrategy(): any { return this._strategy; }
|
||||
|
||||
resolveAndCreateChild(providers: Array<Type|Provider|any[]>): ReflectiveInjector {
|
||||
resolveAndCreateChild(providers: Array<Type<any>|Provider|any[]>): ReflectiveInjector {
|
||||
var ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
|
||||
return this.createChildFromResolved(ResolvedReflectiveProviders);
|
||||
}
|
||||
@@ -656,7 +656,7 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
return inj;
|
||||
}
|
||||
|
||||
resolveAndInstantiate(provider: Type|Provider): any {
|
||||
resolveAndInstantiate(provider: Type<any>|Provider): any {
|
||||
return this.instantiateResolved(ReflectiveInjector.resolve([provider])[0]);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
*/
|
||||
|
||||
import {ListWrapper, MapWrapper} from '../facade/collection';
|
||||
import {Type, isArray, isBlank, isPresent} from '../facade/lang';
|
||||
import {isArray, isBlank, isPresent} from '../facade/lang';
|
||||
import {reflector} from '../reflection/reflection';
|
||||
import {Type} from '../type';
|
||||
|
||||
import {resolveForwardRef} from './forward_ref';
|
||||
import {DependencyMetadata, HostMetadata, InjectMetadata, OptionalMetadata, SelfMetadata, SkipSelfMetadata} from './metadata';
|
||||
@@ -18,6 +19,7 @@ import {InvalidProviderError, MixingMultiProvidersWithRegularProvidersError, NoA
|
||||
import {ReflectiveKey} from './reflective_key';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* `Dependency` is used by the framework to extend DI.
|
||||
* This is internal to Angular and should not be used directly.
|
||||
@@ -54,7 +56,7 @@ const _EMPTY_LIST: any[] = [];
|
||||
*/
|
||||
export interface ResolvedReflectiveProvider {
|
||||
/**
|
||||
* A key, usually a `Type`.
|
||||
* A key, usually a `Type<any>`.
|
||||
*/
|
||||
key: ReflectiveKey;
|
||||
|
||||
@@ -140,7 +142,7 @@ export function resolveReflectiveProvider(provider: Provider): ResolvedReflectiv
|
||||
* Resolve a list of Providers.
|
||||
*/
|
||||
export function resolveReflectiveProviders(
|
||||
providers: Array<Type|Provider|{[k: string]: any}|any[]>): ResolvedReflectiveProvider[] {
|
||||
providers: Array<Type<any>|Provider|{[k: string]: any}|any[]>): ResolvedReflectiveProvider[] {
|
||||
var normalized = _normalizeProviders(providers, []);
|
||||
var resolved = normalized.map(resolveReflectiveProvider);
|
||||
return MapWrapper.values(
|
||||
@@ -185,7 +187,7 @@ export function mergeResolvedReflectiveProviders(
|
||||
}
|
||||
|
||||
function _normalizeProviders(
|
||||
providers: Array<Type|Provider|{[k: string]: any}|ProviderBuilder|any[]>,
|
||||
providers: Array<Type<any>|Provider|{[k: string]: any}|ProviderBuilder|any[]>,
|
||||
res: Provider[]): Provider[] {
|
||||
providers.forEach(b => {
|
||||
if (b instanceof Type) {
|
||||
|
||||
@@ -6,23 +6,24 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Injector, OpaqueToken} from '../di';
|
||||
import {BaseException, unimplemented} from '../facade/exceptions';
|
||||
import {ConcreteType, Type, stringify} from '../facade/lang';
|
||||
import {NgModuleMetadata, ViewEncapsulation} from '../metadata';
|
||||
import {OpaqueToken} from '../di';
|
||||
import {BaseException} from '../facade/exceptions';
|
||||
import {stringify} from '../facade/lang';
|
||||
import {ViewEncapsulation} from '../metadata';
|
||||
import {Type} from '../type';
|
||||
|
||||
import {ComponentFactory} from './component_factory';
|
||||
import {ComponentResolver} from './component_resolver';
|
||||
import {NgModuleFactory} from './ng_module_factory';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Indicates that a component is still being loaded in a synchronous compile.
|
||||
*
|
||||
* @stable
|
||||
*/
|
||||
export class ComponentStillLoadingError extends BaseException {
|
||||
constructor(public compType: Type) {
|
||||
constructor(public compType: Type<any>) {
|
||||
super(`Can't compile synchronously as ${stringify(compType)} is still being loaded!`);
|
||||
}
|
||||
}
|
||||
@@ -57,7 +58,7 @@ export class Compiler {
|
||||
/**
|
||||
* Loads the template and styles of a component and returns the associated `ComponentFactory`.
|
||||
*/
|
||||
compileComponentAsync<T>(component: ConcreteType<T>, ngModule: Type = null):
|
||||
compileComponentAsync<T>(component: Type<T>, ngModule: Type<any> = null):
|
||||
Promise<ComponentFactory<T>> {
|
||||
throw _throwError();
|
||||
}
|
||||
@@ -65,7 +66,7 @@ export class Compiler {
|
||||
* Compiles the given component. All templates have to be either inline or compiled via
|
||||
* `compileComponentAsync` before. Otherwise throws a {@link ComponentStillLoadingError}.
|
||||
*/
|
||||
compileComponentSync<T>(component: ConcreteType<T>, ngModule: Type = null): ComponentFactory<T> {
|
||||
compileComponentSync<T>(component: Type<T>, ngModule: Type<any> = null): ComponentFactory<T> {
|
||||
throw _throwError();
|
||||
}
|
||||
/**
|
||||
@@ -73,27 +74,24 @@ export class Compiler {
|
||||
* in `entryComponents`
|
||||
* have to be inlined. Otherwise throws a {@link ComponentStillLoadingError}.
|
||||
*/
|
||||
compileModuleSync<T>(moduleType: ConcreteType<T>): NgModuleFactory<T> { throw _throwError(); }
|
||||
compileModuleSync<T>(moduleType: Type<T>): NgModuleFactory<T> { throw _throwError(); }
|
||||
|
||||
/**
|
||||
* Compiles the given NgModule and all of its components
|
||||
*/
|
||||
compileModuleAsync<T>(moduleType: ConcreteType<T>): Promise<NgModuleFactory<T>> {
|
||||
throw _throwError();
|
||||
}
|
||||
compileModuleAsync<T>(moduleType: Type<T>): Promise<NgModuleFactory<T>> { throw _throwError(); }
|
||||
|
||||
/**
|
||||
* Same as {@link compileModuleSync} put also creates ComponentFactories for all components.
|
||||
*/
|
||||
compileModuleAndAllComponentsSync<T>(moduleType: ConcreteType<T>):
|
||||
ModuleWithComponentFactories<T> {
|
||||
compileModuleAndAllComponentsSync<T>(moduleType: Type<T>): ModuleWithComponentFactories<T> {
|
||||
throw _throwError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link compileModuleAsync} put also creates ComponentFactories for all components.
|
||||
*/
|
||||
compileModuleAndAllComponentsAsync<T>(moduleType: ConcreteType<T>):
|
||||
compileModuleAndAllComponentsAsync<T>(moduleType: Type<T>):
|
||||
Promise<ModuleWithComponentFactories<T>> {
|
||||
throw _throwError();
|
||||
}
|
||||
@@ -106,7 +104,7 @@ export class Compiler {
|
||||
/**
|
||||
* Clears the cache for the given component/ngModule.
|
||||
*/
|
||||
clearCacheFor(type: Type) {}
|
||||
clearCacheFor(type: Type<any>) {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user