feat: tree-shakeable providers API updates (#22655)
Rename @Injectable({scope -> providedIn}). Instead of {providedIn: APP_ROOT_SCOPE}, accept {providedIn: 'root'}. Also, {providedIn: null} implies the injectable should not be added to any scope. PR Close #22655
This commit is contained in:

committed by
Kara Erickson

parent
21e44c6ba9
commit
db56836425
@ -8,7 +8,7 @@
|
||||
|
||||
import {Type} from '../type';
|
||||
|
||||
import {Injectable, defineInjectable} from './injectable';
|
||||
import {InjectableDef, defineInjectable} from './injectable';
|
||||
|
||||
/**
|
||||
* Creates a token that can be used in a DI Provider.
|
||||
@ -36,12 +36,15 @@ export class InjectionToken<T> {
|
||||
/** @internal */
|
||||
readonly ngMetadataName = 'InjectionToken';
|
||||
|
||||
readonly ngInjectableDef: Injectable|undefined;
|
||||
readonly ngInjectableDef: InjectableDef<T>|undefined;
|
||||
|
||||
constructor(protected _desc: string, options?: {scope: Type<any>, factory: () => T}) {
|
||||
constructor(protected _desc: string, options?: {
|
||||
providedIn?: Type<any>| 'root' | null,
|
||||
factory: () => T
|
||||
}) {
|
||||
if (options !== undefined) {
|
||||
this.ngInjectableDef = defineInjectable({
|
||||
scope: options.scope,
|
||||
providedIn: options.providedIn || 'root',
|
||||
factory: options.factory,
|
||||
});
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user