chore: move injector to being non-internal but private (#10339)

* chore: move injector to being non-internal but private

* Add the new non-internal method to the public API.
This commit is contained in:
Hans 2016-07-28 10:38:29 -07:00 committed by GitHub
parent b58e9ea775
commit a67cc8229d
4 changed files with 6 additions and 7 deletions

View File

@ -44,13 +44,13 @@ export class RuntimeCompiler implements Compiler {
private _compiledNgModuleCache = new Map<Type, NgModuleFactory<any>>(); private _compiledNgModuleCache = new Map<Type, NgModuleFactory<any>>();
constructor( constructor(
private _injector: Injector, private _metadataResolver: CompileMetadataResolver, private __injector: Injector, private _metadataResolver: CompileMetadataResolver,
private _templateNormalizer: DirectiveNormalizer, private _templateParser: TemplateParser, private _templateNormalizer: DirectiveNormalizer, private _templateParser: TemplateParser,
private _styleCompiler: StyleCompiler, private _viewCompiler: ViewCompiler, private _styleCompiler: StyleCompiler, private _viewCompiler: ViewCompiler,
private _ngModuleCompiler: NgModuleCompiler, private _compilerConfig: CompilerConfig, private _ngModuleCompiler: NgModuleCompiler, private _compilerConfig: CompilerConfig,
private _console: Console) {} private _console: Console) {}
get injector(): Injector { return this._injector; } get _injector(): Injector { return this.__injector; }
compileModuleSync<T>(moduleType: ConcreteType<T>): NgModuleFactory<T> { compileModuleSync<T>(moduleType: ConcreteType<T>): NgModuleFactory<T> {
return this._compileModuleAndComponents(moduleType, true).syncResult; return this._compileModuleAndComponents(moduleType, true).syncResult;
@ -381,7 +381,7 @@ class ModuleBoundCompiler implements Compiler, ComponentResolver {
private _delegate: RuntimeCompiler, private _ngModule: ConcreteType<any>, private _delegate: RuntimeCompiler, private _ngModule: ConcreteType<any>,
private _parentComponentResolver: ComponentResolver, private _console: Console) {} private _parentComponentResolver: ComponentResolver, private _console: Console) {}
get injector(): Injector { return this._delegate.injector; } get _injector(): Injector { return this._delegate._injector; }
resolveComponent(component: Type|string): Promise<ComponentFactory<any>> { resolveComponent(component: Type|string): Promise<ComponentFactory<any>> {
if (isString(component)) { if (isString(component)) {

View File

@ -41,10 +41,8 @@ export class ComponentStillLoadingError extends BaseException {
export class Compiler { export class Compiler {
/** /**
* Returns the injector with which the compiler has been created. * Returns the injector with which the compiler has been created.
*
* @internal
*/ */
get injector(): Injector { get _injector(): Injector {
throw new BaseException(`Runtime compiler is not loaded. Tried to read the injector.`); throw new BaseException(`Runtime compiler is not loaded. Tried to read the injector.`);
} }

View File

@ -168,7 +168,7 @@ export class TestBed implements Injector {
// Tests can inject things from the ng module and from the compiler, // Tests can inject things from the ng module and from the compiler,
// but the ng module can't inject things from the compiler and vice versa. // but the ng module can't inject things from the compiler and vice versa.
let result = this._moduleRef.injector.get(token, UNDEFINED); let result = this._moduleRef.injector.get(token, UNDEFINED);
return result === UNDEFINED ? this._compiler.injector.get(token, notFoundValue) : result; return result === UNDEFINED ? this._compiler._injector.get(token, notFoundValue) : result;
} }
execute(tokens: any[], fn: Function): any { execute(tokens: any[], fn: Function): any {

View File

@ -237,6 +237,7 @@ export declare class CollectionChangeRecord {
/** @stable */ /** @stable */
export declare class Compiler { export declare class Compiler {
_injector: Injector;
clearCache(): void; clearCache(): void;
clearCacheFor(type: Type): void; clearCacheFor(type: Type): void;
compileComponentAsync<T>(component: ConcreteType<T>, ngModule?: Type): Promise<ComponentFactory<T>>; compileComponentAsync<T>(component: ConcreteType<T>, ngModule?: Type): Promise<ComponentFactory<T>>;