mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(core): Add recommendation for string tokens on @Inject (#60326)
While still being supported because of ngUpgrade, string tokens are not recommended. Developers should use InjectionTokens or classes as tokens instead. PR Close #60326
This commit is contained in:
parent
04d963c0a5
commit
bb7e948bde
2 changed files with 11 additions and 0 deletions
|
|
@ -905,8 +905,11 @@ export interface InjectableType<T> extends Type<T> {
|
|||
|
||||
// @public
|
||||
export interface InjectDecorator {
|
||||
(token: string): any;
|
||||
(token: any): any;
|
||||
// (undocumented)
|
||||
new (token: string): Inject;
|
||||
// (undocumented)
|
||||
new (token: any): Inject;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,14 @@ import {DecoratorFlags, InternalInjectFlags} from './interface/injector';
|
|||
* @publicApi
|
||||
*/
|
||||
export interface InjectDecorator {
|
||||
/**
|
||||
* Warning: String tokens are not recommended.
|
||||
*
|
||||
* Use an InjectionToken or a class as a token instead.
|
||||
*/
|
||||
(token: string): any;
|
||||
new (token: string): Inject;
|
||||
|
||||
/**
|
||||
* Parameter decorator on a dependency parameter of a class constructor
|
||||
* that specifies a custom provider of the dependency.
|
||||
|
|
|
|||
Loading…
Reference in a new issue