refactor(core): rename `ɵɵInjectableDef` interface to `ɵɵInjectableDeclaration` (#41316)

The other similar interfaces were renamed in https://github.com/angular/angular/pull/41119,
but this one was left since it had existed before Ivy. It looks like the interface was
never actually exposed on npm so it is safe to rename this one too.

PR Close #41316
This commit is contained in:
Pete Bacon Darwin 2021-03-26 12:38:25 +00:00 committed by Zach Arend
parent 71d3b24da3
commit c83fe1698b
20 changed files with 66 additions and 72 deletions

View File

@ -683,14 +683,6 @@ export declare function ɵɵdefineInjectable<T>(opts: {
export declare function ɵɵinject<T>(token: Type<T> | AbstractType<T> | InjectionToken<T>): T;
export declare function ɵɵinject<T>(token: Type<T> | AbstractType<T> | InjectionToken<T>, flags?: InjectFlags): T | null;
/** @codeGenApi */
export declare interface ɵɵInjectableDef<T> {
factory: (t?: Type<any>) => T;
providedIn: InjectorType<any> | 'root' | 'platform' | 'any' | null;
token: unknown;
value: T | undefined;
}
/** @codeGenApi */
export declare function ɵɵinjectAttribute(attrNameToInject: string): string | null;

View File

@ -829,7 +829,7 @@ runInEachFileSystem(() => {
it('should use the correct type name in typings files when an export has a different name in source files',
() => {
// We need to make sure that changes to the typings files use the correct name
// static ɵprov: ɵngcc0.ɵɵInjectableDef<ɵangular_packages_common_common_a>;
// static ɵprov: ɵngcc0.ɵɵInjectableDeclaration<ɵangular_packages_common_common_a>;
mainNgcc({
basePath: '/node_modules',
targetEntryPointPath: '@angular/common',

View File

@ -61,7 +61,7 @@ const CORE_SUPPORTED_SYMBOLS = new Map<string, string>([
['ɵɵinject', 'ɵɵinject'],
['ɵɵFactoryDeclaration', 'ɵɵFactoryDeclaration'],
['ɵsetClassMetadata', 'setClassMetadata'],
['ɵɵInjectableDef', 'ɵɵInjectableDef'],
['ɵɵInjectableDeclaration', 'ɵɵInjectableDeclaration'],
['ɵɵInjectorDeclaration', 'ɵɵInjectorDeclaration'],
['ɵɵNgModuleDeclaration', 'ɵɵNgModuleDeclaration'],
['ɵNgModuleFactory', 'NgModuleFactory'],

View File

@ -218,17 +218,17 @@ FooModule.ɵinj = i0.ɵɵngDeclareInjector({ version: "0.0.0-PLACEHOLDER", ngImp
import * as i0 from "@angular/core";
export declare class Thing {
static ɵfac: i0.ɵɵFactoryDeclaration<Thing, never>;
static ɵprov: i0.ɵɵInjectableDef<Thing>;
static ɵprov: i0.ɵɵInjectableDeclaration<Thing>;
}
export declare class BaseService {
protected thing: Thing;
constructor(thing: Thing);
static ɵfac: i0.ɵɵFactoryDeclaration<BaseService, never>;
static ɵprov: i0.ɵɵInjectableDef<BaseService>;
static ɵprov: i0.ɵɵInjectableDeclaration<BaseService>;
}
export declare class ChildService extends BaseService {
static ɵfac: i0.ɵɵFactoryDeclaration<ChildService, never>;
static ɵprov: i0.ɵɵInjectableDef<ChildService>;
static ɵprov: i0.ɵɵInjectableDeclaration<ChildService>;
}
export declare class FooModule {
static ɵfac: i0.ɵɵFactoryDeclaration<FooModule, never>;
@ -501,7 +501,7 @@ BasicModule.ɵinj = i0.ɵɵngDeclareInjector({ version: "0.0.0-PLACEHOLDER", ngI
import * as i0 from "@angular/core";
export declare class Service {
static ɵfac: i0.ɵɵFactoryDeclaration<Service, never>;
static ɵprov: i0.ɵɵInjectableDef<Service>;
static ɵprov: i0.ɵɵInjectableDeclaration<Service>;
}
export declare class BaseModule {
private service;

View File

@ -56,7 +56,7 @@ MyModule.ɵinj = i0.ɵɵngDeclareInjector({ version: "0.0.0-PLACEHOLDER", ngImpo
import * as i0 from "@angular/core";
export declare class MyService {
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, never>;
static ɵprov: i0.ɵɵInjectableDef<MyService>;
static ɵprov: i0.ɵɵInjectableDeclaration<MyService>;
}
export declare class MyComponent {
constructor(name: string, other: string, s1: MyService, s2: MyService, s4: MyService, s3: MyService, s5: MyService, s6: MyService);
@ -94,7 +94,7 @@ declare class MyDependency {
export declare class MyService {
constructor(dep: MyDependency);
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, never>;
static ɵprov: i0.ɵɵInjectableDef<MyService>;
static ɵprov: i0.ɵɵInjectableDeclaration<MyService>;
}
export {};
@ -127,7 +127,7 @@ declare class MyDependency {
export declare class MyService {
constructor(dep: MyDependency);
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, [null, { optional: true; }]>;
static ɵprov: i0.ɵɵInjectableDef<MyService>;
static ɵprov: i0.ɵɵInjectableDeclaration<MyService>;
}
export {};
@ -156,7 +156,7 @@ MyService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MyService, fac
import * as i0 from "@angular/core";
export declare class MyService {
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, never>;
static ɵprov: i0.ɵɵInjectableDef<MyService>;
static ɵprov: i0.ɵɵInjectableDeclaration<MyService>;
}
/****************************************************************************************************
@ -188,7 +188,7 @@ MyService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MyService, fac
import * as i0 from "@angular/core";
export declare class MyService {
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, never>;
static ɵprov: i0.ɵɵInjectableDef<MyService>;
static ɵprov: i0.ɵɵInjectableDeclaration<MyService>;
}
/****************************************************************************************************
@ -218,7 +218,7 @@ MyService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MyService, fac
import * as i0 from "@angular/core";
export declare class MyService {
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, never>;
static ɵprov: i0.ɵɵInjectableDef<MyService>;
static ɵprov: i0.ɵɵInjectableDeclaration<MyService>;
}
/****************************************************************************************************
@ -255,7 +255,7 @@ MyService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MyService, fac
import * as i0 from "@angular/core";
export declare class MyService {
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, never>;
static ɵprov: i0.ɵɵInjectableDef<MyService>;
static ɵprov: i0.ɵɵInjectableDeclaration<MyService>;
}
/****************************************************************************************************
@ -351,21 +351,21 @@ import { PipeTransform } from '@angular/core';
import * as i0 from "@angular/core";
declare class Service {
static ɵfac: i0.ɵɵFactoryDeclaration<Service, never>;
static ɵprov: i0.ɵɵInjectableDef<Service>;
static ɵprov: i0.ɵɵInjectableDeclaration<Service>;
}
export declare class MyPipe implements PipeTransform {
constructor(service: Service);
transform(value: any, ...args: any[]): any;
static ɵfac: i0.ɵɵFactoryDeclaration<MyPipe, never>;
static ɵpipe: i0.ɵɵPipeDeclaration<MyPipe, "myPipe">;
static ɵprov: i0.ɵɵInjectableDef<MyPipe>;
static ɵprov: i0.ɵɵInjectableDeclaration<MyPipe>;
}
export declare class MyOtherPipe implements PipeTransform {
constructor(service: Service);
transform(value: any, ...args: any[]): any;
static ɵfac: i0.ɵɵFactoryDeclaration<MyOtherPipe, never>;
static ɵpipe: i0.ɵɵPipeDeclaration<MyOtherPipe, "myOtherPipe">;
static ɵprov: i0.ɵɵInjectableDef<MyOtherPipe>;
static ɵprov: i0.ɵɵInjectableDeclaration<MyOtherPipe>;
}
export declare class MyApp {
static ɵfac: i0.ɵɵFactoryDeclaration<MyApp, never>;

View File

@ -2152,7 +2152,7 @@ describe('ngc transformer command-line', () => {
});
});
it('compiles a basic InjectableDef', () => {
it('compiles a basic Injectable definition', () => {
const source = compileService(`
import {Injectable} from '@angular/core';
import {Module} from './module';
@ -2187,7 +2187,7 @@ describe('ngc transformer command-line', () => {
expect(source).toMatch(/\/\*\* @nocollapse \*\/ Service\.ɵprov =/);
});
it('compiles a useValue InjectableDef', () => {
it('compiles a useValue Injectable definition', () => {
const source = compileService(`
import {Injectable} from '@angular/core';
import {Module} from './module';
@ -2203,7 +2203,7 @@ describe('ngc transformer command-line', () => {
expect(source).toMatch(/ɵprov.*return CONST_SERVICE/);
});
it('compiles a useExisting InjectableDef', () => {
it('compiles a useExisting Injectable definition', () => {
const source = compileService(`
import {Injectable} from '@angular/core';
import {Module} from './module';
@ -2220,7 +2220,7 @@ describe('ngc transformer command-line', () => {
expect(source).toMatch(/ɵprov.*return ..\.ɵɵinject\(Existing\)/);
});
it('compiles a useFactory InjectableDef with optional dep', () => {
it('compiles a useFactory Injectable definition with optional dep', () => {
const source = compileService(`
import {Injectable, Optional} from '@angular/core';
import {Module} from './module';
@ -2240,7 +2240,7 @@ describe('ngc transformer command-line', () => {
expect(source).toMatch(/ɵprov.*return ..\(..\.ɵɵinject\(Existing, 8\)/);
});
it('compiles a useFactory InjectableDef with skip-self dep', () => {
it('compiles a useFactory Injectable definition with skip-self dep', () => {
const source = compileService(`
import {Injectable, SkipSelf} from '@angular/core';
import {Module} from './module';

View File

@ -74,8 +74,8 @@ function allTests(os: string) {
expect(jsContents).toContain('Service.ɵprov =');
expect(jsContents).not.toContain('__decorate');
const dtsContents = env.getContents('test.d.ts');
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDef<Dep>;');
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDef<Service>;');
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration<Dep>;');
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration<Service>;');
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration<Dep, never>;');
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration<Service, never>;');
});
@ -95,7 +95,7 @@ function allTests(os: string) {
expect(jsContents).toContain('Store.ɵprov =');
const dtsContents = env.getContents('test.d.ts');
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration<Store<any>, never>;');
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDef<Store<any>>;');
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration<Store<any>>;');
});
it('should compile Injectables with providedIn without errors', () => {
@ -123,8 +123,8 @@ function allTests(os: string) {
expect(jsContents).toContain('providedIn: \'root\' })');
expect(jsContents).not.toContain('__decorate');
const dtsContents = env.getContents('test.d.ts');
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDef<Dep>;');
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDef<Service>;');
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration<Dep>;');
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration<Service>;');
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration<Dep, never>;');
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration<Service, never>;');
});
@ -150,7 +150,7 @@ function allTests(os: string) {
expect(jsContents).toContain(', providedIn: \'root\' });');
expect(jsContents).not.toContain('__decorate');
const dtsContents = env.getContents('test.d.ts');
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDef<Service>;');
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration<Service>;');
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration<Service, never>;');
});
@ -179,7 +179,7 @@ function allTests(os: string) {
expect(jsContents).toContain('return r; }, providedIn: \'root\' });');
expect(jsContents).not.toContain('__decorate');
const dtsContents = env.getContents('test.d.ts');
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDef<Service>;');
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration<Service>;');
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration<Service, never>;');
});
@ -2175,10 +2175,10 @@ function allTests(os: string) {
// Validate that each class's .d.ts declaration also has an injectable
// definition.
expect(dtsContents).toContain('InjectableDef<TestCmp');
expect(dtsContents).toContain('InjectableDef<TestDir');
expect(dtsContents).toContain('InjectableDef<TestPipe');
expect(dtsContents).toContain('InjectableDef<TestNgModule');
expect(dtsContents).toContain('ɵɵInjectableDeclaration<TestCmp');
expect(dtsContents).toContain('ɵɵInjectableDeclaration<TestDir');
expect(dtsContents).toContain('ɵɵInjectableDeclaration<TestPipe');
expect(dtsContents).toContain('ɵɵInjectableDeclaration<TestNgModule');
});
it('should not compile a component and a directive annotation on the same class', () => {

View File

@ -67,7 +67,8 @@ export class Identifiers {
static INJECTOR: o.ExternalReference = {name: 'INJECTOR', moduleName: CORE};
static Injector: o.ExternalReference = {name: 'Injector', moduleName: CORE};
static ɵɵdefineInjectable: o.ExternalReference = {name: 'ɵɵdefineInjectable', moduleName: CORE};
static InjectableDef: o.ExternalReference = {name: 'ɵɵInjectableDef', moduleName: CORE};
static InjectableDeclaration:
o.ExternalReference = {name: 'ɵɵInjectableDeclaration', moduleName: CORE};
static ViewEncapsulation: o.ExternalReference = {
name: 'ViewEncapsulation',
moduleName: CORE,

View File

@ -119,7 +119,8 @@ export function compileInjectable(meta: R3InjectableMetadata): InjectableDef {
const expression = o.importExpr(Identifiers.ɵɵdefineInjectable)
.callFn([injectableProps.toLiteralMap()], undefined, true);
const type = new o.ExpressionType(o.importExpr(
Identifiers.InjectableDef, [typeWithParameters(meta.type.type, meta.typeArgumentCount)]));
Identifiers.InjectableDeclaration,
[typeWithParameters(meta.type.type, meta.typeArgumentCount)]));
return {
expression,

View File

@ -14,7 +14,7 @@ export {ChangeDetectorStatus as ɵChangeDetectorStatus, isDefaultChangeDetection
export {Console as ɵConsole} from './console';
export {getDebugNodeR2 as ɵgetDebugNodeR2} from './debug/debug_node';
export {inject, setCurrentInjector as ɵsetCurrentInjector, ɵɵinject} from './di/injector_compatibility';
export {getInjectableDef as ɵgetInjectableDef, ɵɵInjectableDef, ɵɵInjectorDef} from './di/interface/defs';
export {getInjectableDef as ɵgetInjectableDef, ɵɵInjectableDeclaration, ɵɵInjectorDef} from './di/interface/defs';
export {INJECTOR_SCOPE as ɵINJECTOR_SCOPE} from './di/scope';
export {CurrencyIndex as ɵCurrencyIndex, ExtraLocaleDataIndex as ɵExtraLocaleDataIndex, findLocaleData as ɵfindLocaleData, getLocaleCurrencyCode as ɵgetLocaleCurrencyCode, getLocalePluralCase as ɵgetLocalePluralCase, LocaleDataIndex as ɵLocaleDataIndex, registerLocaleData as ɵregisterLocaleData, unregisterAllLocaleData as ɵunregisterLocaleData} from './i18n/locale_data_api';
export {DEFAULT_LOCALE_ID as ɵDEFAULT_LOCALE_ID} from './i18n/localization';

View File

@ -11,7 +11,7 @@ import {throwProviderNotFoundError} from '../render3/errors_di';
import {assertNotEqual} from '../util/assert';
import {stringify} from '../util/stringify';
import {InjectionToken} from './injection_token';
import {getInjectableDef, ɵɵInjectableDef} from './interface/defs';
import {getInjectableDef, ɵɵInjectableDeclaration} from './interface/defs';
import {InjectFlags} from './interface/injector';
@ -51,12 +51,12 @@ export function setInjectImplementation(
*
* If no injector exists, we can still inject tree-shakable providers which have `providedIn` set to
* `"root"`. This is known as the limp mode injection. In such case the value is stored in the
* `InjectableDef`.
* injectable definition.
*/
export function injectRootLimpMode<T>(
token: Type<T>|AbstractType<T>|InjectionToken<T>, notFoundValue: T|undefined,
flags: InjectFlags): T|null {
const injectableDef: ɵɵInjectableDef<T>|null = getInjectableDef(token);
const injectableDef: ɵɵInjectableDeclaration<T>|null = getInjectableDef(token);
if (injectableDef && injectableDef.providedIn == 'root') {
return injectableDef.value === undefined ? injectableDef.value = injectableDef.factory() :
injectableDef.value;

View File

@ -27,7 +27,7 @@ import {ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, S
* deployed to npm, and should be treated as public api.
*/
export interface ɵɵInjectableDef<T> {
export interface ɵɵInjectableDeclaration<T> {
/**
* Specifies that the given type belongs to a particular injector:
* - `InjectorType` such as `NgModule`,
@ -78,7 +78,7 @@ export interface ɵɵInjectorDef<T> {
}
/**
* A `Type` which has an `InjectableDef` static field.
* A `Type` which has a `ɵprov: ɵɵInjectableDeclaration` static field.
*
* `InjectableType`s contain their own Dependency Injection metadata and are usable in an
* `InjectorDef`-based `StaticInjector.
@ -123,8 +123,8 @@ export interface InjectorTypeWithProviders<T> {
/**
* Construct an `InjectableDef` which defines how a token will be constructed by the DI system, and
* in which injectors (if any) it will be available.
* Construct an injectable definition which defines how a token will be constructed by the DI
* system, and in which injectors (if any) it will be available.
*
* This should be assigned to a static `ɵprov` field on a type, which will then be an
* `InjectableType`.
@ -148,7 +148,7 @@ export function ɵɵdefineInjectable<T>(opts: {
providedIn: opts.providedIn as any || null,
factory: opts.factory,
value: undefined,
} as ɵɵInjectableDef<T>;
} as ɵɵInjectableDeclaration<T>;
}
/**
@ -185,7 +185,7 @@ export function ɵɵdefineInjector(options: {providers?: any[], imports?: any[]}
*
* @param type A type which may have its own (non-inherited) `ɵprov`.
*/
export function getInjectableDef<T>(type: any): ɵɵInjectableDef<T>|null {
export function getInjectableDef<T>(type: any): ɵɵInjectableDeclaration<T>|null {
return getOwnDefinition(type, NG_PROV_DEF) || getOwnDefinition(type, NG_INJECTABLE_DEF);
}
@ -193,7 +193,7 @@ export function getInjectableDef<T>(type: any): ɵɵInjectableDef<T>|null {
* Return definition only if it is defined directly on `type` and is not inherited from a base
* class of `type`.
*/
function getOwnDefinition<T>(type: any, field: string): ɵɵInjectableDef<T>|null {
function getOwnDefinition<T>(type: any, field: string): ɵɵInjectableDeclaration<T>|null {
return type.hasOwnProperty(field) ? type[field] : null;
}
@ -205,7 +205,7 @@ function getOwnDefinition<T>(type: any, field: string): ɵɵInjectableDef<T>|nul
* @deprecated Will be removed in a future version of Angular, where an error will occur in the
* scenario if we find the `ɵprov` on an ancestor only.
*/
export function getInheritedInjectableDef<T>(type: any): ɵɵInjectableDef<T>|null {
export function getInheritedInjectableDef<T>(type: any): ɵɵInjectableDeclaration<T>|null {
const def = type && (type[NG_PROV_DEF] || type[NG_INJECTABLE_DEF]);
if (def) {

View File

@ -21,7 +21,7 @@ import {InjectionToken} from './injection_token';
import {Injector} from './injector';
import {catchInjectorError, injectArgs, NG_TEMP_TOKEN_PATH, setCurrentInjector, THROW_IF_NOT_FOUND, USE_VALUE, ɵɵinject} from './injector_compatibility';
import {INJECTOR} from './injector_token';
import {getInheritedInjectableDef, getInjectableDef, getInjectorDef, InjectorType, InjectorTypeWithProviders, ɵɵInjectableDef} from './interface/defs';
import {getInheritedInjectableDef, getInjectableDef, getInjectorDef, InjectorType, InjectorTypeWithProviders, ɵɵInjectableDeclaration} from './interface/defs';
import {InjectFlags} from './interface/injector';
import {ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, StaticClassProvider, StaticProvider, TypeProvider, ValueProvider} from './interface/provider';
import {NullInjector} from './null_injector';
@ -417,7 +417,7 @@ export class R3Injector {
return record.value as T;
}
private injectableDefInScope(def: ɵɵInjectableDef<any>): boolean {
private injectableDefInScope(def: ɵɵInjectableDeclaration<any>): boolean {
if (!def.providedIn) {
return false;
}

View File

@ -22,7 +22,7 @@
*/
export {ɵɵinject} from './di/injector_compatibility';
export {ɵɵdefineInjectable, ɵɵdefineInjector, ɵɵInjectableDef} from './di/interface/defs';
export {ɵɵdefineInjectable, ɵɵdefineInjector, ɵɵInjectableDeclaration} from './di/interface/defs';
export {NgModuleDef} from './metadata/ng_module_def';
export {ɵɵdefineNgModule} from './render3/definition';
export {ɵɵFactoryDeclaration, ɵɵInjectorDeclaration, ɵɵNgModuleDeclaration} from './render3/interfaces/public_definitions';

View File

@ -10,7 +10,7 @@ import {resolveForwardRef} from '../di/forward_ref';
import {Injector} from '../di/injector';
import {setCurrentInjector} from '../di/injector_compatibility';
import {INJECTOR} from '../di/injector_token';
import {getInjectableDef, ɵɵInjectableDef} from '../di/interface/defs';
import {getInjectableDef, ɵɵInjectableDeclaration} from '../di/interface/defs';
import {INJECTOR_SCOPE} from '../di/scope';
import {NgModuleRef} from '../linker/ng_module_factory';
import {newArray} from '../util/array_utils';
@ -102,7 +102,7 @@ export function resolveNgModuleDep(
return data;
}
const providerDef = data._def.providersByKey[tokenKey];
let injectableDef: ɵɵInjectableDef<any>|null;
let injectableDef: ɵɵInjectableDeclaration<any>|null;
if (providerDef) {
let providerInstance = data._providers[providerDef.index];
if (providerInstance === undefined) {
@ -137,7 +137,7 @@ function moduleTransitivelyPresent(ngModule: NgModuleData, scope: any): boolean
return ngModule._def.modules.indexOf(scope) > -1;
}
function targetsModule(ngModule: NgModuleData, def: ɵɵInjectableDef<any>): boolean {
function targetsModule(ngModule: NgModuleData, def: ɵɵInjectableDeclaration<any>): boolean {
const providedIn = resolveForwardRef(def.providedIn);
return providedIn != null &&
(providedIn === 'any' || providedIn === ngModule._def.scope ||

View File

@ -8,7 +8,7 @@
import {DebugElement__PRE_R3__, DebugEventListener, DebugNode__PRE_R3__, getDebugNode, indexDebugNode, removeDebugNodeFromIndex} from '../debug/debug_node';
import {Injector, resolveForwardRef} from '../di';
import {getInjectableDef, InjectableType, ɵɵInjectableDef} from '../di/interface/defs';
import {getInjectableDef, InjectableType, ɵɵInjectableDeclaration} from '../di/interface/defs';
import {ErrorHandler} from '../error_handler';
import {Type} from '../interface/type';
import {ComponentFactory} from '../linker/component_factory';
@ -174,7 +174,7 @@ const viewDefOverrides = new Map<any, ViewDefinition>();
function debugOverrideProvider(override: ProviderOverride) {
providerOverrides.set(override.token, override);
let injectableDef: ɵɵInjectableDef<any>|null;
let injectableDef: ɵɵInjectableDeclaration<any>|null;
if (typeof override.token === 'function' && (injectableDef = getInjectableDef(override.token)) &&
typeof injectableDef.providedIn === 'function') {
providerOverridesWithScope.set(override.token as InjectableType<any>, override);
@ -197,7 +197,7 @@ function debugClearOverrides() {
// 1) Locate the providers of an element and check if one of them was overwritten
// 2) Change the providers of that element
//
// We only create new datastructures if we need to, to keep perf impact
// We only create new data structures if we need to, to keep perf impact
// reasonable.
function applyProviderOverridesToView(def: ViewDefinition): ViewDefinition {
if (providerOverrides.size === 0) {
@ -253,7 +253,7 @@ function applyProviderOverridesToView(def: ViewDefinition): ViewDefinition {
}
// Notes about the algorithm:
// We only create new datastructures if we need to, to keep perf impact
// We only create new data structures if we need to, to keep perf impact
// reasonable.
function applyProviderOverridesToNgModule(def: NgModuleDefinition): NgModuleDefinition {
const {hasOverrides, hasDeprecatedOverrides} = calcHasOverrides(def);

View File

@ -7,7 +7,7 @@
*/
import {ANALYZE_FOR_ENTRY_COMPONENTS, Compiler, Component, ComponentFactoryResolver, CUSTOM_ELEMENTS_SCHEMA, Directive, forwardRef, getModuleFactory, HostBinding, Inject, Injectable, InjectionToken, Injector, Input, NgModule, NgModuleRef, Optional, Pipe, Provider, Self, Type, ɵivyEnabled as ivyEnabled, ɵɵdefineNgModule as defineNgModule} from '@angular/core';
import {ɵɵdefineInjectable, ɵɵInjectableDef} from '@angular/core/src/di/interface/defs';
import {ɵɵdefineInjectable} from '@angular/core/src/di/interface/defs';
import {getNgModuleDef} from '@angular/core/src/render3/definition';
import {NgModuleData} from '@angular/core/src/view/types';
import {tokenKey} from '@angular/core/src/view/util';

View File

@ -151,11 +151,11 @@ describe('NgModuleRef_ injector', () => {
expect(ref.injector.get(Foo) instanceof Foo).toBeTruthy();
});
it('injects an InjectableDef value', () => {
it('injects an injectable value', () => {
expect(ref.injector.get(Bar) instanceof Bar).toBeTruthy();
});
it('caches InjectableDef values', () => {
it('caches injectable values', () => {
expect(ref.injector.get(Bar)).toBe(ref.injector.get(Bar));
});

View File

@ -7,7 +7,7 @@
*/
import {ResourceLoader} from '@angular/compiler';
import {ApplicationInitStatus, Compiler, COMPILER_OPTIONS, Component, Directive, Injector, InjectorType, LOCALE_ID, ModuleWithComponentFactories, ModuleWithProviders, NgModule, NgModuleFactory, NgZone, Pipe, PlatformRef, Provider, resolveForwardRef, Type, ɵcompileComponent as compileComponent, ɵcompileDirective as compileDirective, ɵcompileNgModuleDefs as compileNgModuleDefs, ɵcompilePipe as compilePipe, ɵDEFAULT_LOCALE_ID as DEFAULT_LOCALE_ID, ɵDirectiveDef as DirectiveDef, ɵgetInjectableDef as getInjectableDef, ɵNG_COMP_DEF as NG_COMP_DEF, ɵNG_DIR_DEF as NG_DIR_DEF, ɵNG_INJ_DEF as NG_INJ_DEF, ɵNG_MOD_DEF as NG_MOD_DEF, ɵNG_PIPE_DEF as NG_PIPE_DEF, ɵNgModuleFactory as R3NgModuleFactory, ɵNgModuleTransitiveScopes as NgModuleTransitiveScopes, ɵNgModuleType as NgModuleType, ɵpatchComponentDefWithScope as patchComponentDefWithScope, ɵRender3ComponentFactory as ComponentFactory, ɵRender3NgModuleRef as NgModuleRef, ɵsetLocaleId as setLocaleId, ɵtransitiveScopesFor as transitiveScopesFor, ɵɵInjectableDef as InjectableDef} from '@angular/core';
import {ApplicationInitStatus, Compiler, COMPILER_OPTIONS, Component, Directive, Injector, InjectorType, LOCALE_ID, ModuleWithComponentFactories, ModuleWithProviders, NgModule, NgModuleFactory, NgZone, Pipe, PlatformRef, Provider, resolveForwardRef, Type, ɵcompileComponent as compileComponent, ɵcompileDirective as compileDirective, ɵcompileNgModuleDefs as compileNgModuleDefs, ɵcompilePipe as compilePipe, ɵDEFAULT_LOCALE_ID as DEFAULT_LOCALE_ID, ɵDirectiveDef as DirectiveDef, ɵgetInjectableDef as getInjectableDef, ɵNG_COMP_DEF as NG_COMP_DEF, ɵNG_DIR_DEF as NG_DIR_DEF, ɵNG_INJ_DEF as NG_INJ_DEF, ɵNG_MOD_DEF as NG_MOD_DEF, ɵNG_PIPE_DEF as NG_PIPE_DEF, ɵNgModuleFactory as R3NgModuleFactory, ɵNgModuleTransitiveScopes as NgModuleTransitiveScopes, ɵNgModuleType as NgModuleType, ɵpatchComponentDefWithScope as patchComponentDefWithScope, ɵRender3ComponentFactory as ComponentFactory, ɵRender3NgModuleRef as NgModuleRef, ɵsetLocaleId as setLocaleId, ɵtransitiveScopesFor as transitiveScopesFor, ɵɵInjectableDeclaration as InjectableDeclaration} from '@angular/core';
import {clearResolutionOfComponentResourcesQueue, isComponentDefPendingResolution, resolveComponentResources, restoreComponentResolutionQueue} from '../../src/metadata/resource_loading';
@ -174,7 +174,7 @@ export class R3TestBedCompiler {
providerDef = {provide: token};
}
const injectableDef: InjectableDef<any>|null =
const injectableDef: InjectableDeclaration<any>|null =
typeof token !== 'string' ? getInjectableDef(token) : null;
const providedIn = injectableDef === null ? null : resolveForwardRef(injectableDef.providedIn);
const overridesBucket =
@ -353,7 +353,7 @@ export class R3TestBedCompiler {
if (this.overriddenModules.size > 0) {
// Module overrides (via `TestBed.overrideModule`) might affect scopes that were previously
// calculated and stored in `transitiveCompileScopes`. If module overrides are present,
// collect all affected modules and reset scopes to force their re-calculatation.
// collect all affected modules and reset scopes to force their re-calculation.
const testingModuleDef = (this.testModuleType as any)[NG_MOD_DEF];
const affectedModules = this.collectModulesAffectedByOverrides(testingModuleDef.imports);
if (affectedModules.size > 0) {

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AbstractType, ApplicationInitStatus, CompilerOptions, Component, Directive, InjectFlags, InjectionToken, Injector, NgModule, NgModuleFactory, NgModuleRef, NgZone, Optional, Pipe, PlatformRef, Provider, SchemaMetadata, SkipSelf, StaticProvider, Type, ɵclearOverrides as clearOverrides, ɵDepFlags as DepFlags, ɵgetInjectableDef as getInjectableDef, ɵINJECTOR_SCOPE as INJECTOR_SCOPE, ɵivyEnabled as ivyEnabled, ɵNodeFlags as NodeFlags, ɵoverrideComponentView as overrideComponentView, ɵoverrideProvider as overrideProvider, ɵstringify as stringify, ɵɵInjectableDef} from '@angular/core';
import {AbstractType, ApplicationInitStatus, CompilerOptions, Component, Directive, InjectFlags, InjectionToken, Injector, NgModule, NgModuleFactory, NgModuleRef, NgZone, Optional, Pipe, PlatformRef, Provider, SchemaMetadata, SkipSelf, StaticProvider, Type, ɵclearOverrides as clearOverrides, ɵDepFlags as DepFlags, ɵgetInjectableDef as getInjectableDef, ɵINJECTOR_SCOPE as INJECTOR_SCOPE, ɵivyEnabled as ivyEnabled, ɵNodeFlags as NodeFlags, ɵoverrideComponentView as overrideComponentView, ɵoverrideProvider as overrideProvider, ɵstringify as stringify, ɵɵInjectableDeclaration} from '@angular/core';
import {AsyncTestCompleter} from './async_test_completer';
import {ComponentFixture} from './component_fixture';
@ -546,7 +546,7 @@ export class TestBedViewEngine implements TestBed {
deps?: any[],
},
deprecated = false): void {
let def: ɵɵInjectableDef<any>|null = null;
let def: ɵɵInjectableDeclaration<any>|null = null;
if (typeof token !== 'string' && (def = getInjectableDef(token)) && def.providedIn === 'root') {
if (provider.useFactory) {
this._rootProviderOverrides.push(