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:
parent
71d3b24da3
commit
c83fe1698b
|
@ -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>): T;
|
||||||
export declare function ɵɵinject<T>(token: Type<T> | AbstractType<T> | InjectionToken<T>, flags?: InjectFlags): T | null;
|
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 */
|
/** @codeGenApi */
|
||||||
export declare function ɵɵinjectAttribute(attrNameToInject: string): string | null;
|
export declare function ɵɵinjectAttribute(attrNameToInject: string): string | null;
|
||||||
|
|
||||||
|
|
|
@ -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',
|
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
|
// 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({
|
mainNgcc({
|
||||||
basePath: '/node_modules',
|
basePath: '/node_modules',
|
||||||
targetEntryPointPath: '@angular/common',
|
targetEntryPointPath: '@angular/common',
|
||||||
|
|
|
@ -61,7 +61,7 @@ const CORE_SUPPORTED_SYMBOLS = new Map<string, string>([
|
||||||
['ɵɵinject', 'ɵɵinject'],
|
['ɵɵinject', 'ɵɵinject'],
|
||||||
['ɵɵFactoryDeclaration', 'ɵɵFactoryDeclaration'],
|
['ɵɵFactoryDeclaration', 'ɵɵFactoryDeclaration'],
|
||||||
['ɵsetClassMetadata', 'setClassMetadata'],
|
['ɵsetClassMetadata', 'setClassMetadata'],
|
||||||
['ɵɵInjectableDef', 'ɵɵInjectableDef'],
|
['ɵɵInjectableDeclaration', 'ɵɵInjectableDeclaration'],
|
||||||
['ɵɵInjectorDeclaration', 'ɵɵInjectorDeclaration'],
|
['ɵɵInjectorDeclaration', 'ɵɵInjectorDeclaration'],
|
||||||
['ɵɵNgModuleDeclaration', 'ɵɵNgModuleDeclaration'],
|
['ɵɵNgModuleDeclaration', 'ɵɵNgModuleDeclaration'],
|
||||||
['ɵNgModuleFactory', 'NgModuleFactory'],
|
['ɵNgModuleFactory', 'NgModuleFactory'],
|
||||||
|
|
|
@ -218,17 +218,17 @@ FooModule.ɵinj = i0.ɵɵngDeclareInjector({ version: "0.0.0-PLACEHOLDER", ngImp
|
||||||
import * as i0 from "@angular/core";
|
import * as i0 from "@angular/core";
|
||||||
export declare class Thing {
|
export declare class Thing {
|
||||||
static ɵfac: i0.ɵɵFactoryDeclaration<Thing, never>;
|
static ɵfac: i0.ɵɵFactoryDeclaration<Thing, never>;
|
||||||
static ɵprov: i0.ɵɵInjectableDef<Thing>;
|
static ɵprov: i0.ɵɵInjectableDeclaration<Thing>;
|
||||||
}
|
}
|
||||||
export declare class BaseService {
|
export declare class BaseService {
|
||||||
protected thing: Thing;
|
protected thing: Thing;
|
||||||
constructor(thing: Thing);
|
constructor(thing: Thing);
|
||||||
static ɵfac: i0.ɵɵFactoryDeclaration<BaseService, never>;
|
static ɵfac: i0.ɵɵFactoryDeclaration<BaseService, never>;
|
||||||
static ɵprov: i0.ɵɵInjectableDef<BaseService>;
|
static ɵprov: i0.ɵɵInjectableDeclaration<BaseService>;
|
||||||
}
|
}
|
||||||
export declare class ChildService extends BaseService {
|
export declare class ChildService extends BaseService {
|
||||||
static ɵfac: i0.ɵɵFactoryDeclaration<ChildService, never>;
|
static ɵfac: i0.ɵɵFactoryDeclaration<ChildService, never>;
|
||||||
static ɵprov: i0.ɵɵInjectableDef<ChildService>;
|
static ɵprov: i0.ɵɵInjectableDeclaration<ChildService>;
|
||||||
}
|
}
|
||||||
export declare class FooModule {
|
export declare class FooModule {
|
||||||
static ɵfac: i0.ɵɵFactoryDeclaration<FooModule, never>;
|
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";
|
import * as i0 from "@angular/core";
|
||||||
export declare class Service {
|
export declare class Service {
|
||||||
static ɵfac: i0.ɵɵFactoryDeclaration<Service, never>;
|
static ɵfac: i0.ɵɵFactoryDeclaration<Service, never>;
|
||||||
static ɵprov: i0.ɵɵInjectableDef<Service>;
|
static ɵprov: i0.ɵɵInjectableDeclaration<Service>;
|
||||||
}
|
}
|
||||||
export declare class BaseModule {
|
export declare class BaseModule {
|
||||||
private service;
|
private service;
|
||||||
|
|
|
@ -56,7 +56,7 @@ MyModule.ɵinj = i0.ɵɵngDeclareInjector({ version: "0.0.0-PLACEHOLDER", ngImpo
|
||||||
import * as i0 from "@angular/core";
|
import * as i0 from "@angular/core";
|
||||||
export declare class MyService {
|
export declare class MyService {
|
||||||
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, never>;
|
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, never>;
|
||||||
static ɵprov: i0.ɵɵInjectableDef<MyService>;
|
static ɵprov: i0.ɵɵInjectableDeclaration<MyService>;
|
||||||
}
|
}
|
||||||
export declare class MyComponent {
|
export declare class MyComponent {
|
||||||
constructor(name: string, other: string, s1: MyService, s2: MyService, s4: MyService, s3: MyService, s5: MyService, s6: MyService);
|
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 {
|
export declare class MyService {
|
||||||
constructor(dep: MyDependency);
|
constructor(dep: MyDependency);
|
||||||
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, never>;
|
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, never>;
|
||||||
static ɵprov: i0.ɵɵInjectableDef<MyService>;
|
static ɵprov: i0.ɵɵInjectableDeclaration<MyService>;
|
||||||
}
|
}
|
||||||
export {};
|
export {};
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ declare class MyDependency {
|
||||||
export declare class MyService {
|
export declare class MyService {
|
||||||
constructor(dep: MyDependency);
|
constructor(dep: MyDependency);
|
||||||
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, [null, { optional: true; }]>;
|
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, [null, { optional: true; }]>;
|
||||||
static ɵprov: i0.ɵɵInjectableDef<MyService>;
|
static ɵprov: i0.ɵɵInjectableDeclaration<MyService>;
|
||||||
}
|
}
|
||||||
export {};
|
export {};
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ MyService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MyService, fac
|
||||||
import * as i0 from "@angular/core";
|
import * as i0 from "@angular/core";
|
||||||
export declare class MyService {
|
export declare class MyService {
|
||||||
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, never>;
|
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";
|
import * as i0 from "@angular/core";
|
||||||
export declare class MyService {
|
export declare class MyService {
|
||||||
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, never>;
|
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";
|
import * as i0 from "@angular/core";
|
||||||
export declare class MyService {
|
export declare class MyService {
|
||||||
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, never>;
|
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";
|
import * as i0 from "@angular/core";
|
||||||
export declare class MyService {
|
export declare class MyService {
|
||||||
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, never>;
|
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";
|
import * as i0 from "@angular/core";
|
||||||
declare class Service {
|
declare class Service {
|
||||||
static ɵfac: i0.ɵɵFactoryDeclaration<Service, never>;
|
static ɵfac: i0.ɵɵFactoryDeclaration<Service, never>;
|
||||||
static ɵprov: i0.ɵɵInjectableDef<Service>;
|
static ɵprov: i0.ɵɵInjectableDeclaration<Service>;
|
||||||
}
|
}
|
||||||
export declare class MyPipe implements PipeTransform {
|
export declare class MyPipe implements PipeTransform {
|
||||||
constructor(service: Service);
|
constructor(service: Service);
|
||||||
transform(value: any, ...args: any[]): any;
|
transform(value: any, ...args: any[]): any;
|
||||||
static ɵfac: i0.ɵɵFactoryDeclaration<MyPipe, never>;
|
static ɵfac: i0.ɵɵFactoryDeclaration<MyPipe, never>;
|
||||||
static ɵpipe: i0.ɵɵPipeDeclaration<MyPipe, "myPipe">;
|
static ɵpipe: i0.ɵɵPipeDeclaration<MyPipe, "myPipe">;
|
||||||
static ɵprov: i0.ɵɵInjectableDef<MyPipe>;
|
static ɵprov: i0.ɵɵInjectableDeclaration<MyPipe>;
|
||||||
}
|
}
|
||||||
export declare class MyOtherPipe implements PipeTransform {
|
export declare class MyOtherPipe implements PipeTransform {
|
||||||
constructor(service: Service);
|
constructor(service: Service);
|
||||||
transform(value: any, ...args: any[]): any;
|
transform(value: any, ...args: any[]): any;
|
||||||
static ɵfac: i0.ɵɵFactoryDeclaration<MyOtherPipe, never>;
|
static ɵfac: i0.ɵɵFactoryDeclaration<MyOtherPipe, never>;
|
||||||
static ɵpipe: i0.ɵɵPipeDeclaration<MyOtherPipe, "myOtherPipe">;
|
static ɵpipe: i0.ɵɵPipeDeclaration<MyOtherPipe, "myOtherPipe">;
|
||||||
static ɵprov: i0.ɵɵInjectableDef<MyOtherPipe>;
|
static ɵprov: i0.ɵɵInjectableDeclaration<MyOtherPipe>;
|
||||||
}
|
}
|
||||||
export declare class MyApp {
|
export declare class MyApp {
|
||||||
static ɵfac: i0.ɵɵFactoryDeclaration<MyApp, never>;
|
static ɵfac: i0.ɵɵFactoryDeclaration<MyApp, never>;
|
||||||
|
|
|
@ -2152,7 +2152,7 @@ describe('ngc transformer command-line', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('compiles a basic InjectableDef', () => {
|
it('compiles a basic Injectable definition', () => {
|
||||||
const source = compileService(`
|
const source = compileService(`
|
||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {Module} from './module';
|
import {Module} from './module';
|
||||||
|
@ -2187,7 +2187,7 @@ describe('ngc transformer command-line', () => {
|
||||||
expect(source).toMatch(/\/\*\* @nocollapse \*\/ Service\.ɵprov =/);
|
expect(source).toMatch(/\/\*\* @nocollapse \*\/ Service\.ɵprov =/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('compiles a useValue InjectableDef', () => {
|
it('compiles a useValue Injectable definition', () => {
|
||||||
const source = compileService(`
|
const source = compileService(`
|
||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {Module} from './module';
|
import {Module} from './module';
|
||||||
|
@ -2203,7 +2203,7 @@ describe('ngc transformer command-line', () => {
|
||||||
expect(source).toMatch(/ɵprov.*return CONST_SERVICE/);
|
expect(source).toMatch(/ɵprov.*return CONST_SERVICE/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('compiles a useExisting InjectableDef', () => {
|
it('compiles a useExisting Injectable definition', () => {
|
||||||
const source = compileService(`
|
const source = compileService(`
|
||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {Module} from './module';
|
import {Module} from './module';
|
||||||
|
@ -2220,7 +2220,7 @@ describe('ngc transformer command-line', () => {
|
||||||
expect(source).toMatch(/ɵprov.*return ..\.ɵɵinject\(Existing\)/);
|
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(`
|
const source = compileService(`
|
||||||
import {Injectable, Optional} from '@angular/core';
|
import {Injectable, Optional} from '@angular/core';
|
||||||
import {Module} from './module';
|
import {Module} from './module';
|
||||||
|
@ -2240,7 +2240,7 @@ describe('ngc transformer command-line', () => {
|
||||||
expect(source).toMatch(/ɵprov.*return ..\(..\.ɵɵinject\(Existing, 8\)/);
|
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(`
|
const source = compileService(`
|
||||||
import {Injectable, SkipSelf} from '@angular/core';
|
import {Injectable, SkipSelf} from '@angular/core';
|
||||||
import {Module} from './module';
|
import {Module} from './module';
|
||||||
|
|
|
@ -74,8 +74,8 @@ function allTests(os: string) {
|
||||||
expect(jsContents).toContain('Service.ɵprov =');
|
expect(jsContents).toContain('Service.ɵprov =');
|
||||||
expect(jsContents).not.toContain('__decorate');
|
expect(jsContents).not.toContain('__decorate');
|
||||||
const dtsContents = env.getContents('test.d.ts');
|
const dtsContents = env.getContents('test.d.ts');
|
||||||
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDef<Dep>;');
|
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration<Dep>;');
|
||||||
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDef<Service>;');
|
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration<Service>;');
|
||||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration<Dep, never>;');
|
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration<Dep, never>;');
|
||||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration<Service, never>;');
|
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration<Service, never>;');
|
||||||
});
|
});
|
||||||
|
@ -95,7 +95,7 @@ function allTests(os: string) {
|
||||||
expect(jsContents).toContain('Store.ɵprov =');
|
expect(jsContents).toContain('Store.ɵprov =');
|
||||||
const dtsContents = env.getContents('test.d.ts');
|
const dtsContents = env.getContents('test.d.ts');
|
||||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration<Store<any>, never>;');
|
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', () => {
|
it('should compile Injectables with providedIn without errors', () => {
|
||||||
|
@ -123,8 +123,8 @@ function allTests(os: string) {
|
||||||
expect(jsContents).toContain('providedIn: \'root\' })');
|
expect(jsContents).toContain('providedIn: \'root\' })');
|
||||||
expect(jsContents).not.toContain('__decorate');
|
expect(jsContents).not.toContain('__decorate');
|
||||||
const dtsContents = env.getContents('test.d.ts');
|
const dtsContents = env.getContents('test.d.ts');
|
||||||
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDef<Dep>;');
|
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration<Dep>;');
|
||||||
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDef<Service>;');
|
expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration<Service>;');
|
||||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration<Dep, never>;');
|
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration<Dep, never>;');
|
||||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDeclaration<Service, 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).toContain(', providedIn: \'root\' });');
|
||||||
expect(jsContents).not.toContain('__decorate');
|
expect(jsContents).not.toContain('__decorate');
|
||||||
const dtsContents = env.getContents('test.d.ts');
|
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>;');
|
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).toContain('return r; }, providedIn: \'root\' });');
|
||||||
expect(jsContents).not.toContain('__decorate');
|
expect(jsContents).not.toContain('__decorate');
|
||||||
const dtsContents = env.getContents('test.d.ts');
|
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>;');
|
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
|
// Validate that each class's .d.ts declaration also has an injectable
|
||||||
// definition.
|
// definition.
|
||||||
expect(dtsContents).toContain('InjectableDef<TestCmp');
|
expect(dtsContents).toContain('ɵɵInjectableDeclaration<TestCmp');
|
||||||
expect(dtsContents).toContain('InjectableDef<TestDir');
|
expect(dtsContents).toContain('ɵɵInjectableDeclaration<TestDir');
|
||||||
expect(dtsContents).toContain('InjectableDef<TestPipe');
|
expect(dtsContents).toContain('ɵɵInjectableDeclaration<TestPipe');
|
||||||
expect(dtsContents).toContain('InjectableDef<TestNgModule');
|
expect(dtsContents).toContain('ɵɵInjectableDeclaration<TestNgModule');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not compile a component and a directive annotation on the same class', () => {
|
it('should not compile a component and a directive annotation on the same class', () => {
|
||||||
|
|
|
@ -67,7 +67,8 @@ export class Identifiers {
|
||||||
static INJECTOR: o.ExternalReference = {name: 'INJECTOR', moduleName: CORE};
|
static INJECTOR: o.ExternalReference = {name: 'INJECTOR', moduleName: CORE};
|
||||||
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 ɵɵ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 = {
|
static ViewEncapsulation: o.ExternalReference = {
|
||||||
name: 'ViewEncapsulation',
|
name: 'ViewEncapsulation',
|
||||||
moduleName: CORE,
|
moduleName: CORE,
|
||||||
|
|
|
@ -119,7 +119,8 @@ export function compileInjectable(meta: R3InjectableMetadata): InjectableDef {
|
||||||
const expression = o.importExpr(Identifiers.ɵɵdefineInjectable)
|
const expression = o.importExpr(Identifiers.ɵɵdefineInjectable)
|
||||||
.callFn([injectableProps.toLiteralMap()], undefined, true);
|
.callFn([injectableProps.toLiteralMap()], undefined, true);
|
||||||
const type = new o.ExpressionType(o.importExpr(
|
const type = new o.ExpressionType(o.importExpr(
|
||||||
Identifiers.InjectableDef, [typeWithParameters(meta.type.type, meta.typeArgumentCount)]));
|
Identifiers.InjectableDeclaration,
|
||||||
|
[typeWithParameters(meta.type.type, meta.typeArgumentCount)]));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
expression,
|
expression,
|
||||||
|
|
|
@ -14,7 +14,7 @@ export {ChangeDetectorStatus as ɵChangeDetectorStatus, isDefaultChangeDetection
|
||||||
export {Console as ɵConsole} from './console';
|
export {Console as ɵConsole} from './console';
|
||||||
export {getDebugNodeR2 as ɵgetDebugNodeR2} from './debug/debug_node';
|
export {getDebugNodeR2 as ɵgetDebugNodeR2} from './debug/debug_node';
|
||||||
export {inject, setCurrentInjector as ɵsetCurrentInjector, ɵɵinject} from './di/injector_compatibility';
|
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 {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 {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';
|
export {DEFAULT_LOCALE_ID as ɵDEFAULT_LOCALE_ID} from './i18n/localization';
|
||||||
|
|
|
@ -11,7 +11,7 @@ import {throwProviderNotFoundError} from '../render3/errors_di';
|
||||||
import {assertNotEqual} from '../util/assert';
|
import {assertNotEqual} from '../util/assert';
|
||||||
import {stringify} from '../util/stringify';
|
import {stringify} from '../util/stringify';
|
||||||
import {InjectionToken} from './injection_token';
|
import {InjectionToken} from './injection_token';
|
||||||
import {getInjectableDef, ɵɵInjectableDef} from './interface/defs';
|
import {getInjectableDef, ɵɵInjectableDeclaration} from './interface/defs';
|
||||||
import {InjectFlags} from './interface/injector';
|
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
|
* 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
|
* `"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>(
|
export function injectRootLimpMode<T>(
|
||||||
token: Type<T>|AbstractType<T>|InjectionToken<T>, notFoundValue: T|undefined,
|
token: Type<T>|AbstractType<T>|InjectionToken<T>, notFoundValue: T|undefined,
|
||||||
flags: InjectFlags): T|null {
|
flags: InjectFlags): T|null {
|
||||||
const injectableDef: ɵɵInjectableDef<T>|null = getInjectableDef(token);
|
const injectableDef: ɵɵInjectableDeclaration<T>|null = getInjectableDef(token);
|
||||||
if (injectableDef && injectableDef.providedIn == 'root') {
|
if (injectableDef && injectableDef.providedIn == 'root') {
|
||||||
return injectableDef.value === undefined ? injectableDef.value = injectableDef.factory() :
|
return injectableDef.value === undefined ? injectableDef.value = injectableDef.factory() :
|
||||||
injectableDef.value;
|
injectableDef.value;
|
||||||
|
|
|
@ -27,7 +27,7 @@ import {ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, S
|
||||||
* deployed to npm, and should be treated as public api.
|
* 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:
|
* Specifies that the given type belongs to a particular injector:
|
||||||
* - `InjectorType` such as `NgModule`,
|
* - `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
|
* `InjectableType`s contain their own Dependency Injection metadata and are usable in an
|
||||||
* `InjectorDef`-based `StaticInjector.
|
* `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
|
* Construct an injectable definition which defines how a token will be constructed by the DI
|
||||||
* in which injectors (if any) it will be available.
|
* 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
|
* This should be assigned to a static `ɵprov` field on a type, which will then be an
|
||||||
* `InjectableType`.
|
* `InjectableType`.
|
||||||
|
@ -148,7 +148,7 @@ export function ɵɵdefineInjectable<T>(opts: {
|
||||||
providedIn: opts.providedIn as any || null,
|
providedIn: opts.providedIn as any || null,
|
||||||
factory: opts.factory,
|
factory: opts.factory,
|
||||||
value: undefined,
|
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`.
|
* @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);
|
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
|
* Return definition only if it is defined directly on `type` and is not inherited from a base
|
||||||
* class of `type`.
|
* 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;
|
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
|
* @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.
|
* 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]);
|
const def = type && (type[NG_PROV_DEF] || type[NG_INJECTABLE_DEF]);
|
||||||
|
|
||||||
if (def) {
|
if (def) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import {InjectionToken} from './injection_token';
|
||||||
import {Injector} from './injector';
|
import {Injector} from './injector';
|
||||||
import {catchInjectorError, injectArgs, NG_TEMP_TOKEN_PATH, setCurrentInjector, THROW_IF_NOT_FOUND, USE_VALUE, ɵɵinject} from './injector_compatibility';
|
import {catchInjectorError, injectArgs, NG_TEMP_TOKEN_PATH, setCurrentInjector, THROW_IF_NOT_FOUND, USE_VALUE, ɵɵinject} from './injector_compatibility';
|
||||||
import {INJECTOR} from './injector_token';
|
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 {InjectFlags} from './interface/injector';
|
||||||
import {ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, StaticClassProvider, StaticProvider, TypeProvider, ValueProvider} from './interface/provider';
|
import {ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, StaticClassProvider, StaticProvider, TypeProvider, ValueProvider} from './interface/provider';
|
||||||
import {NullInjector} from './null_injector';
|
import {NullInjector} from './null_injector';
|
||||||
|
@ -417,7 +417,7 @@ export class R3Injector {
|
||||||
return record.value as T;
|
return record.value as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
private injectableDefInScope(def: ɵɵInjectableDef<any>): boolean {
|
private injectableDefInScope(def: ɵɵInjectableDeclaration<any>): boolean {
|
||||||
if (!def.providedIn) {
|
if (!def.providedIn) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export {ɵɵinject} from './di/injector_compatibility';
|
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 {NgModuleDef} from './metadata/ng_module_def';
|
||||||
export {ɵɵdefineNgModule} from './render3/definition';
|
export {ɵɵdefineNgModule} from './render3/definition';
|
||||||
export {ɵɵFactoryDeclaration, ɵɵInjectorDeclaration, ɵɵNgModuleDeclaration} from './render3/interfaces/public_definitions';
|
export {ɵɵFactoryDeclaration, ɵɵInjectorDeclaration, ɵɵNgModuleDeclaration} from './render3/interfaces/public_definitions';
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {resolveForwardRef} from '../di/forward_ref';
|
||||||
import {Injector} from '../di/injector';
|
import {Injector} from '../di/injector';
|
||||||
import {setCurrentInjector} from '../di/injector_compatibility';
|
import {setCurrentInjector} from '../di/injector_compatibility';
|
||||||
import {INJECTOR} from '../di/injector_token';
|
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 {INJECTOR_SCOPE} from '../di/scope';
|
||||||
import {NgModuleRef} from '../linker/ng_module_factory';
|
import {NgModuleRef} from '../linker/ng_module_factory';
|
||||||
import {newArray} from '../util/array_utils';
|
import {newArray} from '../util/array_utils';
|
||||||
|
@ -102,7 +102,7 @@ export function resolveNgModuleDep(
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
const providerDef = data._def.providersByKey[tokenKey];
|
const providerDef = data._def.providersByKey[tokenKey];
|
||||||
let injectableDef: ɵɵInjectableDef<any>|null;
|
let injectableDef: ɵɵInjectableDeclaration<any>|null;
|
||||||
if (providerDef) {
|
if (providerDef) {
|
||||||
let providerInstance = data._providers[providerDef.index];
|
let providerInstance = data._providers[providerDef.index];
|
||||||
if (providerInstance === undefined) {
|
if (providerInstance === undefined) {
|
||||||
|
@ -137,7 +137,7 @@ function moduleTransitivelyPresent(ngModule: NgModuleData, scope: any): boolean
|
||||||
return ngModule._def.modules.indexOf(scope) > -1;
|
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);
|
const providedIn = resolveForwardRef(def.providedIn);
|
||||||
return providedIn != null &&
|
return providedIn != null &&
|
||||||
(providedIn === 'any' || providedIn === ngModule._def.scope ||
|
(providedIn === 'any' || providedIn === ngModule._def.scope ||
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import {DebugElement__PRE_R3__, DebugEventListener, DebugNode__PRE_R3__, getDebugNode, indexDebugNode, removeDebugNodeFromIndex} from '../debug/debug_node';
|
import {DebugElement__PRE_R3__, DebugEventListener, DebugNode__PRE_R3__, getDebugNode, indexDebugNode, removeDebugNodeFromIndex} from '../debug/debug_node';
|
||||||
import {Injector, resolveForwardRef} from '../di';
|
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 {ErrorHandler} from '../error_handler';
|
||||||
import {Type} from '../interface/type';
|
import {Type} from '../interface/type';
|
||||||
import {ComponentFactory} from '../linker/component_factory';
|
import {ComponentFactory} from '../linker/component_factory';
|
||||||
|
@ -174,7 +174,7 @@ const viewDefOverrides = new Map<any, ViewDefinition>();
|
||||||
|
|
||||||
function debugOverrideProvider(override: ProviderOverride) {
|
function debugOverrideProvider(override: ProviderOverride) {
|
||||||
providerOverrides.set(override.token, override);
|
providerOverrides.set(override.token, override);
|
||||||
let injectableDef: ɵɵInjectableDef<any>|null;
|
let injectableDef: ɵɵInjectableDeclaration<any>|null;
|
||||||
if (typeof override.token === 'function' && (injectableDef = getInjectableDef(override.token)) &&
|
if (typeof override.token === 'function' && (injectableDef = getInjectableDef(override.token)) &&
|
||||||
typeof injectableDef.providedIn === 'function') {
|
typeof injectableDef.providedIn === 'function') {
|
||||||
providerOverridesWithScope.set(override.token as InjectableType<any>, override);
|
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
|
// 1) Locate the providers of an element and check if one of them was overwritten
|
||||||
// 2) Change the providers of that element
|
// 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.
|
// reasonable.
|
||||||
function applyProviderOverridesToView(def: ViewDefinition): ViewDefinition {
|
function applyProviderOverridesToView(def: ViewDefinition): ViewDefinition {
|
||||||
if (providerOverrides.size === 0) {
|
if (providerOverrides.size === 0) {
|
||||||
|
@ -253,7 +253,7 @@ function applyProviderOverridesToView(def: ViewDefinition): ViewDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notes about the algorithm:
|
// 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.
|
// reasonable.
|
||||||
function applyProviderOverridesToNgModule(def: NgModuleDefinition): NgModuleDefinition {
|
function applyProviderOverridesToNgModule(def: NgModuleDefinition): NgModuleDefinition {
|
||||||
const {hasOverrides, hasDeprecatedOverrides} = calcHasOverrides(def);
|
const {hasOverrides, hasDeprecatedOverrides} = calcHasOverrides(def);
|
||||||
|
|
|
@ -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 {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 {getNgModuleDef} from '@angular/core/src/render3/definition';
|
||||||
import {NgModuleData} from '@angular/core/src/view/types';
|
import {NgModuleData} from '@angular/core/src/view/types';
|
||||||
import {tokenKey} from '@angular/core/src/view/util';
|
import {tokenKey} from '@angular/core/src/view/util';
|
||||||
|
|
|
@ -151,11 +151,11 @@ describe('NgModuleRef_ injector', () => {
|
||||||
expect(ref.injector.get(Foo) instanceof Foo).toBeTruthy();
|
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();
|
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));
|
expect(ref.injector.get(Bar)).toBe(ref.injector.get(Bar));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ResourceLoader} from '@angular/compiler';
|
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';
|
import {clearResolutionOfComponentResourcesQueue, isComponentDefPendingResolution, resolveComponentResources, restoreComponentResolutionQueue} from '../../src/metadata/resource_loading';
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ export class R3TestBedCompiler {
|
||||||
providerDef = {provide: token};
|
providerDef = {provide: token};
|
||||||
}
|
}
|
||||||
|
|
||||||
const injectableDef: InjectableDef<any>|null =
|
const injectableDef: InjectableDeclaration<any>|null =
|
||||||
typeof token !== 'string' ? getInjectableDef(token) : null;
|
typeof token !== 'string' ? getInjectableDef(token) : null;
|
||||||
const providedIn = injectableDef === null ? null : resolveForwardRef(injectableDef.providedIn);
|
const providedIn = injectableDef === null ? null : resolveForwardRef(injectableDef.providedIn);
|
||||||
const overridesBucket =
|
const overridesBucket =
|
||||||
|
@ -353,7 +353,7 @@ export class R3TestBedCompiler {
|
||||||
if (this.overriddenModules.size > 0) {
|
if (this.overriddenModules.size > 0) {
|
||||||
// Module overrides (via `TestBed.overrideModule`) might affect scopes that were previously
|
// Module overrides (via `TestBed.overrideModule`) might affect scopes that were previously
|
||||||
// calculated and stored in `transitiveCompileScopes`. If module overrides are present,
|
// 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 testingModuleDef = (this.testModuleType as any)[NG_MOD_DEF];
|
||||||
const affectedModules = this.collectModulesAffectedByOverrides(testingModuleDef.imports);
|
const affectedModules = this.collectModulesAffectedByOverrides(testingModuleDef.imports);
|
||||||
if (affectedModules.size > 0) {
|
if (affectedModules.size > 0) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* 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 {AsyncTestCompleter} from './async_test_completer';
|
||||||
import {ComponentFixture} from './component_fixture';
|
import {ComponentFixture} from './component_fixture';
|
||||||
|
@ -546,7 +546,7 @@ export class TestBedViewEngine implements TestBed {
|
||||||
deps?: any[],
|
deps?: any[],
|
||||||
},
|
},
|
||||||
deprecated = false): void {
|
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 (typeof token !== 'string' && (def = getInjectableDef(token)) && def.providedIn === 'root') {
|
||||||
if (provider.useFactory) {
|
if (provider.useFactory) {
|
||||||
this._rootProviderOverrides.push(
|
this._rootProviderOverrides.push(
|
||||||
|
|
Loading…
Reference in New Issue