refactor(core): removed getter and changed to readonly variable (#19117)
PR Close #19117
This commit is contained in:
@ -29,10 +29,10 @@
|
||||
* @stable
|
||||
*/
|
||||
export class InjectionToken<T> {
|
||||
/** @internal */
|
||||
readonly ngMetadataName = 'InjectionToken';
|
||||
|
||||
constructor(protected _desc: string) {}
|
||||
|
||||
toString(): string { return `InjectionToken ${this._desc}`; }
|
||||
|
||||
/** @internal */
|
||||
get ngMetadataName() { return 'InjectionToken'; }
|
||||
}
|
||||
|
@ -282,8 +282,7 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
_constructionCounter: number = 0;
|
||||
/** @internal */
|
||||
public _providers: ResolvedReflectiveProvider[];
|
||||
/** @internal */
|
||||
public _parent: Injector|null;
|
||||
public readonly parent: Injector|null;
|
||||
|
||||
keyIds: number[];
|
||||
objs: any[];
|
||||
@ -292,7 +291,7 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
*/
|
||||
constructor(_providers: ResolvedReflectiveProvider[], _parent?: Injector) {
|
||||
this._providers = _providers;
|
||||
this._parent = _parent || null;
|
||||
this.parent = _parent || null;
|
||||
|
||||
const len = _providers.length;
|
||||
|
||||
@ -309,8 +308,6 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
return this._getByKey(ReflectiveKey.get(token), null, notFoundValue);
|
||||
}
|
||||
|
||||
get parent(): Injector|null { return this._parent; }
|
||||
|
||||
resolveAndCreateChild(providers: Provider[]): ReflectiveInjector {
|
||||
const ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
|
||||
return this.createChildFromResolved(ResolvedReflectiveProviders);
|
||||
@ -318,7 +315,7 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
|
||||
createChildFromResolved(providers: ResolvedReflectiveProvider[]): ReflectiveInjector {
|
||||
const inj = new ReflectiveInjector_(providers);
|
||||
inj._parent = this;
|
||||
(inj as{parent: Injector | null}).parent = this;
|
||||
return inj;
|
||||
}
|
||||
|
||||
@ -436,7 +433,7 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
let inj: Injector|null;
|
||||
|
||||
if (visibility instanceof SkipSelf) {
|
||||
inj = this._parent;
|
||||
inj = this.parent;
|
||||
} else {
|
||||
inj = this;
|
||||
}
|
||||
@ -445,7 +442,7 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
const inj_ = <ReflectiveInjector_>inj;
|
||||
const obj = inj_._getObjByKeyId(key.id);
|
||||
if (obj !== UNDEFINED) return obj;
|
||||
inj = inj_._parent;
|
||||
inj = inj_.parent;
|
||||
}
|
||||
if (inj !== null) {
|
||||
return inj.get(key.token, notFoundValue);
|
||||
|
@ -27,6 +27,7 @@ import {resolveForwardRef} from './forward_ref';
|
||||
* @deprecated No replacement
|
||||
*/
|
||||
export class ReflectiveKey {
|
||||
public readonly displayName: string;
|
||||
/**
|
||||
* Private
|
||||
*/
|
||||
@ -34,13 +35,9 @@ export class ReflectiveKey {
|
||||
if (!token) {
|
||||
throw new Error('Token must be defined!');
|
||||
}
|
||||
this.displayName = stringify(this.token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stringified token.
|
||||
*/
|
||||
get displayName(): string { return stringify(this.token); }
|
||||
|
||||
/**
|
||||
* Retrieves a `Key` for a token.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user