fix(core): fix typing on injector.get to omit 'any' (#60202)

This commit further restricts the deprecated type on injector.get to exclude
all but `string`. Progresses towards #48408

BREAKING CHANGE: The `any` overload has been removed from
`injector.get`. It now only supports `ProviderToken<T>` and (deprecated
since v4) `string`.

PR Close #60202
This commit is contained in:
Andrew Scott
2025-03-04 10:26:16 -08:00
committed by Andrew Kushnir
parent 0cff9a12d3
commit ff772d7800
3 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -695,7 +695,7 @@ export abstract class EnvironmentInjector implements Injector {
// @deprecated
abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
// @deprecated (undocumented)
abstract get(token: any, notFoundValue?: any): any;
abstract get<T>(token: string | ProviderToken<T>, notFoundValue?: any): any;
// @deprecated
abstract runInContext<ReturnT>(fn: () => ReturnT): ReturnT;
}
@@ -966,7 +966,7 @@ export abstract class Injector {
// @deprecated
abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
// @deprecated (undocumented)
abstract get(token: any, notFoundValue?: any): any;
abstract get<T>(token: string | ProviderToken<T>, notFoundValue?: any): any;
// (undocumented)
static NULL: Injector;
// (undocumented)
+1 -1
View File
@@ -94,7 +94,7 @@ export abstract class Injector {
* @deprecated from v4.0.0 use ProviderToken<T>
* @suppress {duplicate}
*/
abstract get(token: any, notFoundValue?: any): any;
abstract get<T>(token: string | ProviderToken<T>, notFoundValue?: any): any;
/**
* @deprecated from v5 use the new signature Injector.create(options)
+1 -1
View File
@@ -163,7 +163,7 @@ export abstract class EnvironmentInjector implements Injector {
* @deprecated from v4.0.0 use ProviderToken<T>
* @suppress {duplicate}
*/
abstract get(token: any, notFoundValue?: any): any;
abstract get<T>(token: string | ProviderToken<T>, notFoundValue?: any): any;
/**
* Runs the given function in the context of this `EnvironmentInjector`.