@ -60,7 +60,7 @@ export const Compiler_compileModuleAndAllComponentsSync__POST_R3__: <T>(moduleTy
|
||||
ModuleWithComponentFactories<T> = function<T>(moduleType: Type<T>):
|
||||
ModuleWithComponentFactories<T> {
|
||||
const ngModuleFactory = Compiler_compileModuleSync__POST_R3__(moduleType);
|
||||
const moduleDef = getNgModuleDef(moduleType) !;
|
||||
const moduleDef = getNgModuleDef(moduleType)!;
|
||||
const componentFactories =
|
||||
maybeUnwrapFn(moduleDef.declarations)
|
||||
.reduce((factories: ComponentFactory<any>[], declaration: Type<any>) => {
|
||||
@ -133,7 +133,9 @@ export class Compiler {
|
||||
/**
|
||||
* Returns the id for a given NgModule, if one is defined and known to the compiler.
|
||||
*/
|
||||
getModuleId(moduleType: Type<any>): string|undefined { return undefined; }
|
||||
getModuleId(moduleType: Type<any>): string|undefined {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,8 +14,8 @@ import {ComponentFactory, ComponentRef} from './component_factory';
|
||||
import {NgModuleRef} from './ng_module_factory';
|
||||
|
||||
export function noComponentFactoryError(component: Function) {
|
||||
const error = Error(
|
||||
`No component factory found for ${stringify(component)}. Did you add it to @NgModule.entryComponents?`);
|
||||
const error = Error(`No component factory found for ${
|
||||
stringify(component)}. Did you add it to @NgModule.entryComponents?`);
|
||||
(error as any)[ERROR_COMPONENT] = component;
|
||||
return error;
|
||||
}
|
||||
@ -28,7 +28,7 @@ export function getComponent(error: Error): Type<any> {
|
||||
|
||||
|
||||
class _NullComponentFactoryResolver implements ComponentFactoryResolver {
|
||||
resolveComponentFactory<T>(component: {new (...args: any[]): T}): ComponentFactory<T> {
|
||||
resolveComponentFactory<T>(component: {new(...args: any[]): T}): ComponentFactory<T> {
|
||||
throw noComponentFactoryError(component);
|
||||
}
|
||||
}
|
||||
@ -63,7 +63,7 @@ export class CodegenComponentFactoryResolver implements ComponentFactoryResolver
|
||||
}
|
||||
}
|
||||
|
||||
resolveComponentFactory<T>(component: {new (...args: any[]): T}): ComponentFactory<T> {
|
||||
resolveComponentFactory<T>(component: {new(...args: any[]): T}): ComponentFactory<T> {
|
||||
let factory = this._factories.get(component);
|
||||
if (!factory && this._parent) {
|
||||
factory = this._parent.resolveComponentFactory(component);
|
||||
|
@ -48,7 +48,9 @@ export class ElementRef<T extends any = any> {
|
||||
*/
|
||||
public nativeElement: T;
|
||||
|
||||
constructor(nativeElement: T) { this.nativeElement = nativeElement; }
|
||||
constructor(nativeElement: T) {
|
||||
this.nativeElement = nativeElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
@ -43,6 +43,8 @@ export function getModuleFactory__POST_R3__(id: string): NgModuleFactory<any> {
|
||||
*/
|
||||
export const getModuleFactory: (id: string) => NgModuleFactory<any> = getModuleFactory__PRE_R3__;
|
||||
|
||||
function noModuleError(id: string, ): Error {
|
||||
function noModuleError(
|
||||
id: string,
|
||||
): Error {
|
||||
return new Error(`No module with ID ${id} loaded`);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ export function registerModuleFactory(id: string, factory: NgModuleFactory<any>)
|
||||
modules.set(id, factory);
|
||||
}
|
||||
|
||||
function assertSameOrNotExisting(id: string, type: Type<any>| null, incoming: Type<any>): void {
|
||||
function assertSameOrNotExisting(id: string, type: Type<any>|null, incoming: Type<any>): void {
|
||||
if (type && type !== incoming) {
|
||||
throw new Error(
|
||||
`Duplicate module registered for ${id} - ${stringify(type)} vs ${stringify(type.name)}`);
|
||||
|
@ -13,7 +13,7 @@ import {flatten} from '../util/array_utils';
|
||||
import {getSymbolIterator} from '../util/symbol';
|
||||
|
||||
function symbolIterator<T>(this: QueryList<T>): Iterator<T> {
|
||||
return ((this as any as{_results: Array<T>})._results as any)[getSymbolIterator()]();
|
||||
return ((this as any as {_results: Array<T>})._results as any)[getSymbolIterator()]();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,9 +49,9 @@ export class QueryList<T> implements Iterable<T> {
|
||||
|
||||
readonly length: number = 0;
|
||||
// TODO(issue/24571): remove '!'.
|
||||
readonly first !: T;
|
||||
readonly first!: T;
|
||||
// TODO(issue/24571): remove '!'.
|
||||
readonly last !: T;
|
||||
readonly last!: T;
|
||||
|
||||
constructor() {
|
||||
// This function should be declared on the prototype, but doing so there will cause the class
|
||||
@ -67,7 +67,9 @@ export class QueryList<T> implements Iterable<T> {
|
||||
* See
|
||||
* [Array.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
|
||||
*/
|
||||
map<U>(fn: (item: T, index: number, array: T[]) => U): U[] { return this._results.map(fn); }
|
||||
map<U>(fn: (item: T, index: number, array: T[]) => U): U[] {
|
||||
return this._results.map(fn);
|
||||
}
|
||||
|
||||
/**
|
||||
* See
|
||||
@ -97,7 +99,9 @@ export class QueryList<T> implements Iterable<T> {
|
||||
* See
|
||||
* [Array.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
|
||||
*/
|
||||
forEach(fn: (item: T, index: number, array: T[]) => void): void { this._results.forEach(fn); }
|
||||
forEach(fn: (item: T, index: number, array: T[]) => void): void {
|
||||
this._results.forEach(fn);
|
||||
}
|
||||
|
||||
/**
|
||||
* See
|
||||
@ -110,9 +114,13 @@ export class QueryList<T> implements Iterable<T> {
|
||||
/**
|
||||
* Returns a copy of the internal results list as an Array.
|
||||
*/
|
||||
toArray(): T[] { return this._results.slice(); }
|
||||
toArray(): T[] {
|
||||
return this._results.slice();
|
||||
}
|
||||
|
||||
toString(): string { return this._results.toString(); }
|
||||
toString(): string {
|
||||
return this._results.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the stored data of the query list, and resets the `dirty` flag to `false`, so that
|
||||
@ -123,19 +131,23 @@ export class QueryList<T> implements Iterable<T> {
|
||||
*/
|
||||
reset(resultsTree: Array<T|any[]>): void {
|
||||
this._results = flatten(resultsTree);
|
||||
(this as{dirty: boolean}).dirty = false;
|
||||
(this as{length: number}).length = this._results.length;
|
||||
(this as{last: T}).last = this._results[this.length - 1];
|
||||
(this as{first: T}).first = this._results[0];
|
||||
(this as {dirty: boolean}).dirty = false;
|
||||
(this as {length: number}).length = this._results.length;
|
||||
(this as {last: T}).last = this._results[this.length - 1];
|
||||
(this as {first: T}).first = this._results[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers a change event by emitting on the `changes` {@link EventEmitter}.
|
||||
*/
|
||||
notifyOnChanges(): void { (this.changes as EventEmitter<any>).emit(this); }
|
||||
notifyOnChanges(): void {
|
||||
(this.changes as EventEmitter<any>).emit(this);
|
||||
}
|
||||
|
||||
/** internal */
|
||||
setDirty() { (this as{dirty: boolean}).dirty = true; }
|
||||
setDirty() {
|
||||
(this as {dirty: boolean}).dirty = true;
|
||||
}
|
||||
|
||||
/** internal */
|
||||
destroy(): void {
|
||||
@ -148,5 +160,5 @@ export class QueryList<T> implements Iterable<T> {
|
||||
// there) and this declaration is left here to ensure that TypeScript considers QueryList to
|
||||
// implement the Iterable interface. This is required for template type-checking of NgFor loops
|
||||
// over QueryLists to work correctly, since QueryList must be assignable to NgIterable.
|
||||
[Symbol.iterator] !: () => Iterator<T>;
|
||||
[Symbol.iterator]!: () => Iterator<T>;
|
||||
}
|
||||
|
@ -32,13 +32,13 @@ export abstract class SystemJsNgModuleLoaderConfig {
|
||||
* Prefix to add when computing the name of the factory module for a given module name.
|
||||
*/
|
||||
// TODO(issue/24571): remove '!'.
|
||||
factoryPathPrefix !: string;
|
||||
factoryPathPrefix!: string;
|
||||
|
||||
/**
|
||||
* Suffix to add when computing the name of the factory module for a given module name.
|
||||
*/
|
||||
// TODO(issue/24571): remove '!'.
|
||||
factoryPathSuffix !: string;
|
||||
factoryPathSuffix!: string;
|
||||
}
|
||||
|
||||
const DEFAULT_CONFIG: SystemJsNgModuleLoaderConfig = {
|
||||
|
Reference in New Issue
Block a user