From c83fe1698bfb4f8c04183b3cf365481bb6460e3d Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Fri, 26 Mar 2021 12:38:25 +0000 Subject: [PATCH] =?UTF-8?q?refactor(core):=20rename=20`=C9=B5=C9=B5Injecta?= =?UTF-8?q?bleDef`=20interface=20to=20`=C9=B5=C9=B5InjectableDeclaration`?= =?UTF-8?q?=20(#41316)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- goldens/public-api/core/core.d.ts | 8 ------- .../ngcc/test/integration/ngcc_spec.ts | 2 +- .../src/ngtsc/imports/src/core.ts | 2 +- .../ng_modules/GOLDEN_PARTIAL.js | 8 +++---- .../r3_view_compiler_di/di/GOLDEN_PARTIAL.js | 20 ++++++++--------- packages/compiler-cli/test/ngc_spec.ts | 10 ++++----- .../compiler-cli/test/ngtsc/ngtsc_spec.ts | 22 +++++++++---------- packages/compiler/src/identifiers.ts | 3 ++- .../compiler/src/injectable_compiler_2.ts | 3 ++- packages/core/src/core_private_export.ts | 2 +- packages/core/src/di/inject_switch.ts | 6 ++--- packages/core/src/di/interface/defs.ts | 16 +++++++------- packages/core/src/di/r3_injector.ts | 4 ++-- packages/core/src/r3_symbols.ts | 2 +- packages/core/src/view/ng_module.ts | 6 ++--- packages/core/src/view/services.ts | 8 +++---- .../test/linker/ng_module_integration_spec.ts | 2 +- packages/core/test/view/ng_module_spec.ts | 4 ++-- .../core/testing/src/r3_test_bed_compiler.ts | 6 ++--- packages/core/testing/src/test_bed.ts | 4 ++-- 20 files changed, 66 insertions(+), 72 deletions(-) diff --git a/goldens/public-api/core/core.d.ts b/goldens/public-api/core/core.d.ts index e5ed21e911..b0d0c9b19f 100644 --- a/goldens/public-api/core/core.d.ts +++ b/goldens/public-api/core/core.d.ts @@ -683,14 +683,6 @@ export declare function ɵɵdefineInjectable(opts: { export declare function ɵɵinject(token: Type | AbstractType | InjectionToken): T; export declare function ɵɵinject(token: Type | AbstractType | InjectionToken, flags?: InjectFlags): T | null; -/** @codeGenApi */ -export declare interface ɵɵInjectableDef { - factory: (t?: Type) => T; - providedIn: InjectorType | 'root' | 'platform' | 'any' | null; - token: unknown; - value: T | undefined; -} - /** @codeGenApi */ export declare function ɵɵinjectAttribute(attrNameToInject: string): string | null; diff --git a/packages/compiler-cli/ngcc/test/integration/ngcc_spec.ts b/packages/compiler-cli/ngcc/test/integration/ngcc_spec.ts index 1420293481..6c5af582df 100644 --- a/packages/compiler-cli/ngcc/test/integration/ngcc_spec.ts +++ b/packages/compiler-cli/ngcc/test/integration/ngcc_spec.ts @@ -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', diff --git a/packages/compiler-cli/src/ngtsc/imports/src/core.ts b/packages/compiler-cli/src/ngtsc/imports/src/core.ts index e952336dd9..09d2c26bc9 100644 --- a/packages/compiler-cli/src/ngtsc/imports/src/core.ts +++ b/packages/compiler-cli/src/ngtsc/imports/src/core.ts @@ -61,7 +61,7 @@ const CORE_SUPPORTED_SYMBOLS = new Map([ ['ɵɵinject', 'ɵɵinject'], ['ɵɵFactoryDeclaration', 'ɵɵFactoryDeclaration'], ['ɵsetClassMetadata', 'setClassMetadata'], - ['ɵɵInjectableDef', 'ɵɵInjectableDef'], + ['ɵɵInjectableDeclaration', 'ɵɵInjectableDeclaration'], ['ɵɵInjectorDeclaration', 'ɵɵInjectorDeclaration'], ['ɵɵNgModuleDeclaration', 'ɵɵNgModuleDeclaration'], ['ɵNgModuleFactory', 'NgModuleFactory'], diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/GOLDEN_PARTIAL.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/GOLDEN_PARTIAL.js index c3038d1b96..aebc857eab 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/GOLDEN_PARTIAL.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/GOLDEN_PARTIAL.js @@ -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; - static ɵprov: i0.ɵɵInjectableDef; + static ɵprov: i0.ɵɵInjectableDeclaration; } export declare class BaseService { protected thing: Thing; constructor(thing: Thing); static ɵfac: i0.ɵɵFactoryDeclaration; - static ɵprov: i0.ɵɵInjectableDef; + static ɵprov: i0.ɵɵInjectableDeclaration; } export declare class ChildService extends BaseService { static ɵfac: i0.ɵɵFactoryDeclaration; - static ɵprov: i0.ɵɵInjectableDef; + static ɵprov: i0.ɵɵInjectableDeclaration; } export declare class FooModule { static ɵfac: i0.ɵɵFactoryDeclaration; @@ -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; - static ɵprov: i0.ɵɵInjectableDef; + static ɵprov: i0.ɵɵInjectableDeclaration; } export declare class BaseModule { private service; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/GOLDEN_PARTIAL.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/GOLDEN_PARTIAL.js index 3fff571e69..1b15eacfd1 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/GOLDEN_PARTIAL.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/GOLDEN_PARTIAL.js @@ -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; - static ɵprov: i0.ɵɵInjectableDef; + static ɵprov: i0.ɵɵInjectableDeclaration; } 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; - static ɵprov: i0.ɵɵInjectableDef; + static ɵprov: i0.ɵɵInjectableDeclaration; } export {}; @@ -127,7 +127,7 @@ declare class MyDependency { export declare class MyService { constructor(dep: MyDependency); static ɵfac: i0.ɵɵFactoryDeclaration; - static ɵprov: i0.ɵɵInjectableDef; + static ɵprov: i0.ɵɵInjectableDeclaration; } 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; - static ɵprov: i0.ɵɵInjectableDef; + static ɵprov: i0.ɵɵInjectableDeclaration; } /**************************************************************************************************** @@ -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; - static ɵprov: i0.ɵɵInjectableDef; + static ɵprov: i0.ɵɵInjectableDeclaration; } /**************************************************************************************************** @@ -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; - static ɵprov: i0.ɵɵInjectableDef; + static ɵprov: i0.ɵɵInjectableDeclaration; } /**************************************************************************************************** @@ -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; - static ɵprov: i0.ɵɵInjectableDef; + static ɵprov: i0.ɵɵInjectableDeclaration; } /**************************************************************************************************** @@ -351,21 +351,21 @@ import { PipeTransform } from '@angular/core'; import * as i0 from "@angular/core"; declare class Service { static ɵfac: i0.ɵɵFactoryDeclaration; - static ɵprov: i0.ɵɵInjectableDef; + static ɵprov: i0.ɵɵInjectableDeclaration; } export declare class MyPipe implements PipeTransform { constructor(service: Service); transform(value: any, ...args: any[]): any; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; - static ɵprov: i0.ɵɵInjectableDef; + static ɵprov: i0.ɵɵInjectableDeclaration; } export declare class MyOtherPipe implements PipeTransform { constructor(service: Service); transform(value: any, ...args: any[]): any; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; - static ɵprov: i0.ɵɵInjectableDef; + static ɵprov: i0.ɵɵInjectableDeclaration; } export declare class MyApp { static ɵfac: i0.ɵɵFactoryDeclaration; diff --git a/packages/compiler-cli/test/ngc_spec.ts b/packages/compiler-cli/test/ngc_spec.ts index a18743add7..1d958a3226 100644 --- a/packages/compiler-cli/test/ngc_spec.ts +++ b/packages/compiler-cli/test/ngc_spec.ts @@ -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'; diff --git a/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts b/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts index 95c0ef5209..4968375eb3 100644 --- a/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts +++ b/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts @@ -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;'); - expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDef;'); + expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration;'); + expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration;'); expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration;'); expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration;'); }); @@ -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, never>;'); - expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDef>;'); + expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration>;'); }); 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;'); - expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDef;'); + expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration;'); + expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration;'); expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration;'); expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration;'); }); @@ -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;'); + expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration;'); expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration;'); }); @@ -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;'); + expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration;'); expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration;'); }); @@ -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 { diff --git a/packages/compiler/src/identifiers.ts b/packages/compiler/src/identifiers.ts index 15dca640cb..82e893d00b 100644 --- a/packages/compiler/src/identifiers.ts +++ b/packages/compiler/src/identifiers.ts @@ -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, diff --git a/packages/compiler/src/injectable_compiler_2.ts b/packages/compiler/src/injectable_compiler_2.ts index 68b7fdb737..a7ec24b676 100644 --- a/packages/compiler/src/injectable_compiler_2.ts +++ b/packages/compiler/src/injectable_compiler_2.ts @@ -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, diff --git a/packages/core/src/core_private_export.ts b/packages/core/src/core_private_export.ts index edf5f40807..39e2d396f8 100644 --- a/packages/core/src/core_private_export.ts +++ b/packages/core/src/core_private_export.ts @@ -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'; diff --git a/packages/core/src/di/inject_switch.ts b/packages/core/src/di/inject_switch.ts index 531481a18c..d90b6caeee 100644 --- a/packages/core/src/di/inject_switch.ts +++ b/packages/core/src/di/inject_switch.ts @@ -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( token: Type|AbstractType|InjectionToken, notFoundValue: T|undefined, flags: InjectFlags): T|null { - const injectableDef: ɵɵInjectableDef|null = getInjectableDef(token); + const injectableDef: ɵɵInjectableDeclaration|null = getInjectableDef(token); if (injectableDef && injectableDef.providedIn == 'root') { return injectableDef.value === undefined ? injectableDef.value = injectableDef.factory() : injectableDef.value; diff --git a/packages/core/src/di/interface/defs.ts b/packages/core/src/di/interface/defs.ts index 9c4395aff2..690c62933f 100644 --- a/packages/core/src/di/interface/defs.ts +++ b/packages/core/src/di/interface/defs.ts @@ -27,7 +27,7 @@ import {ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, S * deployed to npm, and should be treated as public api. */ -export interface ɵɵInjectableDef { +export interface ɵɵInjectableDeclaration { /** * Specifies that the given type belongs to a particular injector: * - `InjectorType` such as `NgModule`, @@ -78,7 +78,7 @@ export interface ɵɵInjectorDef { } /** - * 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 { /** - * 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(opts: { providedIn: opts.providedIn as any || null, factory: opts.factory, value: undefined, - } as ɵɵInjectableDef; + } as ɵɵInjectableDeclaration; } /** @@ -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(type: any): ɵɵInjectableDef|null { +export function getInjectableDef(type: any): ɵɵInjectableDeclaration|null { return getOwnDefinition(type, NG_PROV_DEF) || getOwnDefinition(type, NG_INJECTABLE_DEF); } @@ -193,7 +193,7 @@ export function getInjectableDef(type: any): ɵɵInjectableDef|null { * Return definition only if it is defined directly on `type` and is not inherited from a base * class of `type`. */ -function getOwnDefinition(type: any, field: string): ɵɵInjectableDef|null { +function getOwnDefinition(type: any, field: string): ɵɵInjectableDeclaration|null { return type.hasOwnProperty(field) ? type[field] : null; } @@ -205,7 +205,7 @@ function getOwnDefinition(type: any, field: string): ɵɵInjectableDef|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(type: any): ɵɵInjectableDef|null { +export function getInheritedInjectableDef(type: any): ɵɵInjectableDeclaration|null { const def = type && (type[NG_PROV_DEF] || type[NG_INJECTABLE_DEF]); if (def) { diff --git a/packages/core/src/di/r3_injector.ts b/packages/core/src/di/r3_injector.ts index 1cf239b9a7..cca8801595 100644 --- a/packages/core/src/di/r3_injector.ts +++ b/packages/core/src/di/r3_injector.ts @@ -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): boolean { + private injectableDefInScope(def: ɵɵInjectableDeclaration): boolean { if (!def.providedIn) { return false; } diff --git a/packages/core/src/r3_symbols.ts b/packages/core/src/r3_symbols.ts index 7d2d0e74b9..bcf2b0c903 100644 --- a/packages/core/src/r3_symbols.ts +++ b/packages/core/src/r3_symbols.ts @@ -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'; diff --git a/packages/core/src/view/ng_module.ts b/packages/core/src/view/ng_module.ts index 1c038d78ae..27b6713654 100644 --- a/packages/core/src/view/ng_module.ts +++ b/packages/core/src/view/ng_module.ts @@ -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|null; + let injectableDef: ɵɵInjectableDeclaration|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): boolean { +function targetsModule(ngModule: NgModuleData, def: ɵɵInjectableDeclaration): boolean { const providedIn = resolveForwardRef(def.providedIn); return providedIn != null && (providedIn === 'any' || providedIn === ngModule._def.scope || diff --git a/packages/core/src/view/services.ts b/packages/core/src/view/services.ts index 9879646758..1116f444e1 100644 --- a/packages/core/src/view/services.ts +++ b/packages/core/src/view/services.ts @@ -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(); function debugOverrideProvider(override: ProviderOverride) { providerOverrides.set(override.token, override); - let injectableDef: ɵɵInjectableDef|null; + let injectableDef: ɵɵInjectableDeclaration|null; if (typeof override.token === 'function' && (injectableDef = getInjectableDef(override.token)) && typeof injectableDef.providedIn === 'function') { providerOverridesWithScope.set(override.token as InjectableType, 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); diff --git a/packages/core/test/linker/ng_module_integration_spec.ts b/packages/core/test/linker/ng_module_integration_spec.ts index 6f3e70a3d4..e5f2b36329 100644 --- a/packages/core/test/linker/ng_module_integration_spec.ts +++ b/packages/core/test/linker/ng_module_integration_spec.ts @@ -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'; diff --git a/packages/core/test/view/ng_module_spec.ts b/packages/core/test/view/ng_module_spec.ts index 29daf7da35..9d762b511e 100644 --- a/packages/core/test/view/ng_module_spec.ts +++ b/packages/core/test/view/ng_module_spec.ts @@ -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)); }); diff --git a/packages/core/testing/src/r3_test_bed_compiler.ts b/packages/core/testing/src/r3_test_bed_compiler.ts index f5efc15cab..c849f36e32 100644 --- a/packages/core/testing/src/r3_test_bed_compiler.ts +++ b/packages/core/testing/src/r3_test_bed_compiler.ts @@ -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|null = + const injectableDef: InjectableDeclaration|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) { diff --git a/packages/core/testing/src/test_bed.ts b/packages/core/testing/src/test_bed.ts index 5a40de6703..4dcf1b0b9e 100644 --- a/packages/core/testing/src/test_bed.ts +++ b/packages/core/testing/src/test_bed.ts @@ -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|null = null; + let def: ɵɵInjectableDeclaration|null = null; if (typeof token !== 'string' && (def = getInjectableDef(token)) && def.providedIn === 'root') { if (provider.useFactory) { this._rootProviderOverrides.push(